cardType.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. <template>
  2. <view class="content">
  3. <view class="content1">
  4. <view v-for='item in cardTypeList'>
  5. <view class='flex row flex-between'>
  6. <view class="left flex">
  7. <view class="f-text flex flex-all-center">{{item.circleName[0]}}</view>
  8. <view class="text">{{item.circleName}}</view>
  9. </view>
  10. <view class="right">
  11. <image src="../../static/imgs/mySet/del.png" class="img" mode="widthFix"
  12. v-if='item.circleName!="默认分类"' @click="del(item)"></image>
  13. <image src="../../static/imgs/mySet/zd.png" class="img" mode="widthFix" @click="stick(item)">
  14. </image>
  15. </view>
  16. </view>
  17. </view>
  18. </view>
  19. <u-modal showCancelButton='true' @confirm='$u.debounce(confirm, 500)' @cancel='show=false' :show="show"
  20. title="新增分类" confirmColor="#112253">
  21. <view class="slot-content">
  22. <u--input v-model="cardTypeData.circleName" placeholder="输入分类名称,2-8个字符" border="none"></u--input>
  23. </view>
  24. </u-modal>
  25. <view @click='add' class='button'>新增</view>
  26. <u-toast ref="uToast"></u-toast>
  27. </view>
  28. </template>
  29. <script>
  30. var that;
  31. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  32. export default {
  33. mixins: [MescrollMixin],
  34. data() {
  35. return {
  36. show: false,
  37. cardTypeList: [],
  38. cardTypeData: {},
  39. userInfo: {},
  40. canReset: false,
  41. };
  42. },
  43. onLoad() {
  44. that = this
  45. },
  46. onShow() {
  47. this.userInfo = uni.getStorageSync("userInfo")
  48. this.cardTypeData.commonId = uni.getStorageSync("userInfo").id
  49. this.getList()
  50. },
  51. methods: {
  52. getList() {
  53. uni.showLoading({
  54. title: '数据加载中'
  55. })
  56. this.$request.baseRequest('admin.unimall.cardClassifyInfo', 'list', {
  57. commonId: uni.getStorageSync("userInfo").id
  58. }, failres => {
  59. console.log('res+++++', failres.errmsg)
  60. this.$refs.uToast.show({
  61. type: 'error',
  62. message: failres.errmsg,
  63. })
  64. uni.hideLoading()
  65. }).then(res => {
  66. // this.cardTypeList = res.data.items
  67. uni.hideLoading()
  68. debugger
  69. if (res.data.items.length > 0) {
  70. for (var i = 0; i < res.data.items.length; i++) {
  71. res.data.items[i].name = res.data.items[i].circleName[0]
  72. }
  73. // var itemIndex = res.data.items.findIndex((item) => {
  74. // return item.topMarking == 1
  75. // })
  76. // if (itemIndex != -1) {
  77. // var data = res.data.items.splice(itemIndex, 1)
  78. // res.data.items = data.concat(res.data.items)
  79. // } else {
  80. // res.data.items = [].concat(res.data.items)
  81. // }
  82. this.cardTypeList = res.data.items
  83. } else {
  84. this.cardTypeList = []
  85. }
  86. })
  87. },
  88. del(item) {
  89. uni.showLoading({
  90. title: '加载中',
  91. mask: true
  92. })
  93. this.$request.baseRequest('admin.unimall.cardClassifyInfo', 'delete', {
  94. commonId: uni.getStorageSync("userInfo").id,
  95. id: item.id
  96. }, failres => {
  97. console.log('res+++++', failres.errmsg)
  98. uni.showToast({
  99. title: failres.errmsg,
  100. icon: 'none',
  101. duration: 2000
  102. })
  103. uni.hideLoading()
  104. }).then(res => {
  105. uni.hideLoading()
  106. this.$refs.uToast.show({
  107. type: 'success',
  108. message: '删除成功!',
  109. complete() {
  110. that.getList()
  111. }
  112. })
  113. })
  114. },
  115. stick(item) {
  116. uni.showLoading({
  117. title: '加载中',
  118. mask: true
  119. })
  120. var type = '',
  121. type1 = '',
  122. data = {}
  123. if (item.id) {
  124. type = 'admin.unimall.cardClassifyInfo'
  125. type1 = 'top'
  126. data = {
  127. cardClassifyInfo: JSON.stringify({
  128. id: item.id
  129. })
  130. }
  131. }
  132. this.$request.baseRequest(type, type1, data, failres => {
  133. console.log('res+++++', failres.errmsg)
  134. uni.showToast({
  135. title: failres.errmsg,
  136. icon: 'none',
  137. duration: 2000
  138. })
  139. uni.hideLoading()
  140. }).then(res => {
  141. uni.hideLoading()
  142. this.$refs.uToast.show({
  143. type: 'success',
  144. message: '置顶成功!',
  145. complete() {
  146. that.getList()
  147. }
  148. })
  149. })
  150. },
  151. add() {
  152. this.show = true
  153. },
  154. confirm() {
  155. if (!this.cardTypeData.circleName) {
  156. uni.showToast({
  157. title: '分类名称不能为空!',
  158. icon: 'none',
  159. duration: 2000
  160. })
  161. return
  162. }
  163. if (this.cardTypeData.circleName < 2 || this.cardTypeData.circleName > 8) {
  164. uni.showToast({
  165. title: '类别名称2-8个字!',
  166. icon: 'none',
  167. duration: 2000
  168. })
  169. return
  170. }
  171. this.$request.baseRequest('admin.unimall.cardClassifyInfo', 'add', {
  172. cardClassifyInfo: JSON.stringify(this.cardTypeData)
  173. }, failres => {
  174. console.log('res+++++', failres.errmsg)
  175. this.$refs.uToast.show({
  176. type: 'error',
  177. message: failres.errmsg,
  178. })
  179. uni.hideLoading()
  180. }).then(res => {
  181. uni.hideLoading()
  182. this.show = false
  183. this.cardTypeData = {
  184. commonId: uni.getStorageSync("userInfo").id,
  185. }
  186. this.$refs.uToast.show({
  187. type: 'success',
  188. message: '操作成功',
  189. complete() {
  190. that.getList()
  191. }
  192. })
  193. })
  194. }
  195. }
  196. }
  197. </script>
  198. <style lang="scss" scoped>
  199. .content1 {
  200. .row {
  201. margin: 20rpx 20rpx 0 20rpx;
  202. background-color: #fff;
  203. padding: 20rpx;
  204. border-radius: 20rpx;
  205. .f-text {
  206. width: 58rpx;
  207. height: 58rpx;
  208. background-color: #112253;
  209. border-radius: 50%;
  210. color: #fff;
  211. margin-right: 20rpx;
  212. font-size: 32rpx;
  213. }
  214. .img {
  215. width: 48rpx;
  216. margin-left: 20rpx;
  217. }
  218. }
  219. }
  220. .button {
  221. position: fixed;
  222. bottom: 108rpx;
  223. width: calc(100% - 40rpx);
  224. padding: 24rpx 0;
  225. color: #fff;
  226. background-color: #112253;
  227. text-align: center;
  228. margin: 0 20rpx;
  229. border-radius: 20rpx;
  230. }
  231. </style>