cardType.vue 5.8 KB

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