cardType.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  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. for (let i = 0; i < this.cardTypeList.length; i++) {
  69. if (this.cardTypeList[i].topMarking == 0) {
  70. if (i == 0) {
  71. this.cardTypeList.unshift({
  72. circleName: '默认分类',
  73. name: '默'
  74. });
  75. } else {
  76. this.cardTypeList.splice(i, 0, {
  77. circleName: '默认分类',
  78. name: '默'
  79. })
  80. }
  81. return
  82. }
  83. }
  84. })
  85. },
  86. del(item) {
  87. uni.showLoading({
  88. title: '加载中',
  89. mask: true
  90. })
  91. this.$request.baseRequest('admin.unimall.cardClassifyInfo', 'delete', {
  92. commonId: uni.getStorageSync("userInfo").id,
  93. id: item.id
  94. }, failres => {
  95. console.log('res+++++', failres.errmsg)
  96. uni.showToast({
  97. title: failres.errmsg,
  98. icon: 'none',
  99. duration: 2000
  100. })
  101. uni.hideLoading()
  102. }).then(res => {
  103. uni.hideLoading()
  104. this.$refs.uToast.show({
  105. type: 'success',
  106. message: '删除成功!',
  107. complete() {
  108. that.getList()
  109. }
  110. })
  111. })
  112. },
  113. stick(item) {
  114. uni.showLoading({
  115. title: '加载中',
  116. mask: true
  117. })
  118. var type = '',
  119. type1 = '',
  120. data = {}
  121. if (item.id) {
  122. type = 'admin.unimall.cardClassifyInfo'
  123. type1 = 'top'
  124. data = {
  125. cardClassifyInfo: JSON.stringify({
  126. id: item.id
  127. })
  128. }
  129. } else {
  130. type = 'admin.unimall.cardClassifyInfo'
  131. type1 = 'topDefault'
  132. data = {
  133. cardClassifyInfo: JSON.stringify({
  134. commonId: this.cardTypeData.commonId
  135. })
  136. }
  137. }
  138. this.$request.baseRequest(type, type1, data, failres => {
  139. console.log('res+++++', failres.errmsg)
  140. uni.showToast({
  141. title: failres.errmsg,
  142. icon: 'none',
  143. duration: 2000
  144. })
  145. uni.hideLoading()
  146. }).then(res => {
  147. uni.hideLoading()
  148. this.$refs.uToast.show({
  149. type: 'success',
  150. message: '置顶成功!',
  151. complete() {
  152. that.getList()
  153. }
  154. })
  155. })
  156. },
  157. add() {
  158. this.show = true
  159. },
  160. confirm() {
  161. if (!this.cardTypeData.circleName) {
  162. uni.showToast({
  163. title: '分类名称不能为空!',
  164. icon: 'none',
  165. duration: 2000
  166. })
  167. return
  168. }
  169. if (this.cardTypeData.circleName < 2 || this.cardTypeData.circleName > 8) {
  170. uni.showToast({
  171. title: '类别名称2-8个字!',
  172. icon: 'none',
  173. duration: 2000
  174. })
  175. return
  176. }
  177. this.$request.baseRequest('admin.unimall.cardClassifyInfo', 'add', {
  178. cardClassifyInfo: JSON.stringify(this.cardTypeData)
  179. }, failres => {
  180. console.log('res+++++', failres.errmsg)
  181. this.$refs.uToast.show({
  182. type: 'error',
  183. message: failres.errmsg,
  184. })
  185. uni.hideLoading()
  186. }).then(res => {
  187. uni.hideLoading()
  188. this.show = false
  189. this.cardTypeData = {
  190. commonId: uni.getStorageSync("userInfo").id,
  191. }
  192. this.$refs.uToast.show({
  193. type: 'success',
  194. message: '操作成功',
  195. complete() {
  196. that.getList()
  197. }
  198. })
  199. })
  200. }
  201. }
  202. }
  203. </script>
  204. <style lang="scss" scoped>
  205. .content1 {
  206. .row {
  207. margin: 20rpx 20rpx 0 20rpx;
  208. background-color: #fff;
  209. padding: 20rpx;
  210. border-radius: 20rpx;
  211. .f-text {
  212. width: 58rpx;
  213. height: 58rpx;
  214. background-color: #112253;
  215. border-radius: 50%;
  216. color: #fff;
  217. margin-right: 20rpx;
  218. font-size: 32rpx;
  219. }
  220. .img {
  221. width: 48rpx;
  222. margin-left: 20rpx;
  223. }
  224. }
  225. }
  226. .button {
  227. position: fixed;
  228. bottom: 108rpx;
  229. width: calc(100% - 40rpx);
  230. padding: 24rpx 0;
  231. color: #fff;
  232. background-color: #112253;
  233. text-align: center;
  234. margin: 0 20rpx;
  235. border-radius: 20rpx;
  236. }
  237. </style>