level.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. <template>
  2. <view class="container">
  3. <view class="list">
  4. <view class="item" v-for="(item,index) in list" :key="index">
  5. <view class="top flex flex-y-center box-pack-between">
  6. <view class="name">{{item.name}}</view>
  7. <view class="flex-y-center">
  8. <view class="del" @click="del(item.id)">删除</view>
  9. <!-- <switch :checked="item.status==1?true:false" @change="onTypeChange" :data-index="index"
  10. color="#247EFF" class="type-btn" /> -->
  11. </view>
  12. </view>
  13. <navigator :url="`./add?id=${item.id}`"
  14. class="content flex flex-y-center" hover-class="nav-hover">
  15. <view class="cell flex flex-y-center">
  16. <view class="title">折扣:</view>
  17. <view class="desc">{{item.discount}}</view>
  18. </view>
  19. <view class="cell flex flex-y-center arr-r">
  20. <view class="title">等级:</view>
  21. <view class="desc">{{item.level}}</view>
  22. </view>
  23. </navigator>
  24. </view>
  25. <view class="no-more">没有更多内容了~</view>
  26. </view>
  27. <view class="footer-bar">
  28. <view class="content flex flex-center">
  29. <navigator url="./add" class="btn">+新增等级</navigator>
  30. </view>
  31. </view>
  32. </view>
  33. </template>
  34. <script>
  35. export default {
  36. data() {
  37. return {
  38. store_id: "",
  39. list: [
  40. {
  41. name:"白金",
  42. },{
  43. name:"黄金",
  44. },
  45. ],
  46. page: 1,
  47. is_bottom: false,
  48. }
  49. },
  50. onLoad(options) {
  51. this.store_id = options.store_id
  52. },
  53. onShow() {
  54. this.getData();
  55. },
  56. onReachBottom() {
  57. // if (!this.is_bottom) {
  58. // this.getData(this.page + 1)
  59. // }
  60. },
  61. methods: {
  62. del(id) {
  63. uni.showModal({
  64. title: '提示',
  65. content: '是否要删除?',
  66. showCancel: true,
  67. cancelText: '取消',
  68. confirmText: '确定',
  69. success: res => {
  70. if (res.confirm) {
  71. this.request({
  72. url: 'Smdcshop/level_delect',
  73. data: {
  74. id:id,
  75. },
  76. }).then(res => {
  77. console.log(res, "res")
  78. if (res.code === 200 || res.code === "200") {
  79. uni.showToast({
  80. title: "删除成功",
  81. icon: "none",
  82. })
  83. setTimeout(() => {
  84. this.getData()
  85. }, 2000)
  86. }
  87. }).catch((res) => {
  88. uni.showToast({
  89. title: res.message,
  90. icon: "none",
  91. })
  92. });
  93. }
  94. },
  95. fail: () => {},
  96. complete: () => {}
  97. });
  98. },
  99. onTypeChange(e) {
  100. console.log(e)
  101. let a = e.detail.value ? 1 : 2;
  102. this.checked(a, e.currentTarget.dataset.index);
  103. },
  104. checked(a, index) {
  105. this.request({
  106. url: 'Smdcshop/print_state',
  107. data: {
  108. is_show: a,
  109. id: this.list[index].id,
  110. },
  111. }).then(res => {
  112. if (res.code == "200") {
  113. uni.showToast({
  114. title: "修改成功",
  115. icon: "none",
  116. })
  117. }
  118. }).catch((res) => {
  119. uni.showToast({
  120. title: res.message,
  121. icon: "none",
  122. })
  123. this.$nextTick(() => {
  124. this.list[index].state = 2
  125. })
  126. });
  127. },
  128. getData() {
  129. this.request({
  130. url: 'Smdcshop/level_index',
  131. data: {
  132. admin_id: uni.getStorageSync("admin_id"),
  133. }
  134. }).then(res => {
  135. if (res.code == 200) {
  136. this.list = res.data
  137. }
  138. })
  139. }
  140. }
  141. }
  142. </script>
  143. <style>
  144. @import url("../static/css/common.css");
  145. .del {
  146. height: 44rpx;
  147. line-height: 44rpx;
  148. padding: 0 20rpx;
  149. font-size: 24rpx;
  150. background-color: #FF5722;
  151. margin-right:40rpx;
  152. color: #fff;
  153. border-radius: 4rpx;
  154. }
  155. page {
  156. background-color: #F4F5F7;
  157. }
  158. .list {
  159. padding: 30rpx 25rpx;
  160. }
  161. .list .item {
  162. border-radius: 8rpx;
  163. overflow: hidden;
  164. padding-left: 30rpx;
  165. border-left: 8rpx solid #247EFF;
  166. background-color: #fff;
  167. margin-bottom: 30rpx;
  168. }
  169. .list .item .top {
  170. height: 80rpx;
  171. border-bottom: 1rpx solid #f5f5f5;
  172. }
  173. .list .item .top .name {
  174. font-size: 30rpx;
  175. line-height: 80rpx;
  176. font-weight: bold;
  177. }
  178. .list .item .top .type-btn {
  179. zoom: 0.7;
  180. margin-right: 25rpx;
  181. }
  182. .list .item .content {
  183. padding: 20rpx 0 24rpx;
  184. }
  185. .list .item .content .cell {
  186. flex: none;
  187. width: 50%;
  188. box-sizing: border-box;
  189. padding-right: 30rpx;
  190. font-size: 26rpx;
  191. line-height: 37rpx;
  192. color: #666;
  193. }
  194. .list .item .content .cell .title {
  195. color: #99A0AD;
  196. }
  197. </style>