cardType.vue 5.8 KB

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