imgList.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <template>
  2. <view class="caseList">
  3. <uni-menubar title="图片管理" />
  4. <tm-search v-model="albumParams.keyword" color="blue" @confirm="getAlbumList"></tm-search>
  5. <tm-tabs color="blue" @change="tabClick" v-model="activeIndex" :list="allCateList" range-key="name"
  6. align="left">
  7. </tm-tabs>
  8. <view style="display: flex;justify-content: space-between;flex-wrap: wrap;" class="px-20">
  9. <view style="width: 50%;" v-for="(item,index) in albumList" :key="index">
  10. <tm-sheet :padding="[0,0]" :margin="[10,10]">
  11. <tm-images :previmage="false" :src="item.path" @click="albumDetail(item)" mode='widthFix' width="100%" :height="260"></tm-images>
  12. <view class="px-15">
  13. <view class="mt-20" style="font-size: 26rpx;">
  14. {{item.name}}
  15. </view>
  16. <view class="pt-20 pb-20"
  17. style="font-size: 24rpx;display: flex;justify-content: space-between;">
  18. <text>共<text style="color:#2196F3">{{item.pic_count}}</text>个相关图片</text>
  19. <tm-icons v-if="item.is_edit" :size="30" color="blue" name="icon-edit"
  20. @click="editClick(item)"></tm-icons>
  21. </view>
  22. </view>
  23. </tm-sheet>
  24. </view>
  25. </view>
  26. <tm-poup v-if="addShow" v-model="addShow" position="bottom" height="70%" :round="0">
  27. <view class="pa-20">
  28. <view class="text-xl text-bold">图集编辑</view>
  29. <tm-input name="name" required title="图集标题" v-model="addForm.name"></tm-input>
  30. <picker @change="bindPickerChange" :value="addForm.cate_id" range-key="name" :range="cateList">
  31. <tm-input required title="选择分类" placeholder="请选择分类" disabled
  32. :value="addForm.cate_id ? cateList.find(v=>v.id == addForm.cate_id)['name'] : '请选择分类'">
  33. </tm-input>
  34. </picker>
  35. <view class="py-12 px-24 mx-12 round-3 border-b-1 grey text">
  36. <text class="text-size-n text-weight-b ">上传封面图片</text>
  37. <text class="text-grey text-size-xs px-10">(最多可以上传1张)</text>
  38. </view>
  39. <view class="py-32 mx-12">
  40. <tm-upload ref="upload" :code="200" :max="1" :tips="false" :grid="4"
  41. url="https://cardoa.platomix.net/api/upload" url-key="data" :auto-upload="true" :header="header"
  42. :filelist.sync="addForm.path"></tm-upload>
  43. </view>
  44. <view class="px-24">
  45. <tm-button block @click="saveAlbum">确定提交</tm-button>
  46. </view>
  47. </view>
  48. </tm-poup>
  49. <tm-flotbutton v-if="user.card_id>0" @click="addShow = true" label="添加" :show-text="true"
  50. color="bg-gradient-blue-accent">
  51. </tm-flotbutton>
  52. </view>
  53. </template>
  54. <script>
  55. export default {
  56. data() {
  57. return {
  58. title: "",
  59. activeIndex: 0,
  60. albumList: [],
  61. albumParams: {
  62. cate_id: 0, //分类id
  63. keyword: "",
  64. page: 1 //分页页码,数字类型
  65. },
  66. albumFinish: false,
  67. albumLoding: false,
  68. isShow: 0,
  69. header: {
  70. 'Authorization': uni.getStorageSync('token'),
  71. 'Content-Type': 'multipart/form-data'
  72. },
  73. cateList: [],
  74. allCateList: [{
  75. 'name': '全部',
  76. 'id': 0
  77. }],
  78. addShow: false,
  79. addForm: {
  80. name: '',
  81. cate_id: '',
  82. path: []
  83. },
  84. }
  85. },
  86. onLoad() {
  87. this.getCatList()
  88. this.getAlbumList()
  89. },
  90. onReachBottom(e) {
  91. this.albumScroll()
  92. },
  93. computed: {
  94. user() {
  95. return this.$tm.vx.state().user.userInfo || {}
  96. }
  97. },
  98. methods: {
  99. getAlbumList() {
  100. this.$tm.request.post('album/list', this.albumParams).then(res => {
  101. this.albumList = res.data
  102. })
  103. },
  104. // 获取分类
  105. getCatList(id) {
  106. this.$tm.request.post('album/cate').then(res => {
  107. this.cateList = res.data
  108. this.allCateList = [...this.allCateList, ...this.cateList]
  109. })
  110. },
  111. tabClick(e) {
  112. this.activeIndex = e
  113. this.albumParams.cate_id = this.allCateList[e].id
  114. this.getAlbumList()
  115. },
  116. albumScroll() {
  117. this.albumParams.page++
  118. this.$tm.request.post('album/list', this.albumParams).then(res => {
  119. if (res.data.length > 0) {
  120. res.data.forEach(val => {
  121. this.albumList.push(val)
  122. })
  123. }
  124. })
  125. },
  126. albumDetail(item) {
  127. uni.navigateTo({
  128. url: "/pages/list/caseDetail?id=" + item.id + "&card_id=" + uni.getStorageSync('card_id')
  129. })
  130. },
  131. editClick(item) {
  132. uni.navigateTo({
  133. url: '/pages/list/editCase?album_id=' + item.id
  134. })
  135. },
  136. bindPickerChange(o) {
  137. this.addForm.cate_id = this.cateList[o.detail.value].id
  138. },
  139. saveAlbum() {
  140. this.addForm.path = this.addForm.path[0]
  141. this.$tm.request.post('album/update', this.addForm).then(res => {
  142. uni.navigateTo({
  143. url: '/pages/list/editCase?album_id=' + res.data.id
  144. })
  145. })
  146. }
  147. }
  148. }
  149. </script>
  150. <style scoped lang="scss">
  151. .caseList {
  152. // background-color: #f5f5f5;
  153. }
  154. </style>