trainingClass.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. <template>
  2. <view class="shop-page">
  3. <scroll-view
  4. scroll-y
  5. class="shop-list"
  6. >
  7. <block v-if="!$util.isEmpty(shopList)">
  8. <view
  9. class="shop-item"
  10. v-for="(item, index) in shopList"
  11. :key="index"
  12. >
  13. <image
  14. class="avatar"
  15. :src="item.cover"
  16. alt="商品图"
  17. />
  18. <view class="info">
  19. <view class="info-name">{{ item.name }}</view>
  20. <view class="info-address">
  21. ¥{{ item.tuition }}
  22. </view>
  23. </view>
  24. <view :class="['edit']">
  25. <text
  26. class="iconfont iconbianji"
  27. @click="editItem(item.id)"
  28. > </text>
  29. <text
  30. class="iconfont iconshanchu1"
  31. @click="delItem(item.id)"
  32. > </text>
  33. </view>
  34. </view>
  35. </block>
  36. <block v-else>
  37. <AppWrapperEmpty
  38. title="暂无数据"
  39. :is-empty="$util.isEmpty(shopList)"
  40. />
  41. </block>
  42. </scroll-view>
  43. <view class="under-bar">
  44. <button
  45. :class="['admin-button-com', 'middle', 'blue']"
  46. @click="addItem"
  47. >
  48. 添加
  49. </button>
  50. </view>
  51. </view>
  52. </template>
  53. <script>
  54. import { getPxClassDataApi, pxClassDel } from "@/api/product/index";
  55. import AppWrapperEmpty from "@/components/app-wrapper-empty";
  56. export default {
  57. components: { AppWrapperEmpty },
  58. data () {
  59. return {
  60. shopList: []
  61. };
  62. },
  63. onPullDownRefresh() {
  64. this.getData().then(res => {
  65. uni.stopPullDownRefresh();
  66. })
  67. },
  68. methods: {
  69. init() {
  70. this.getData()
  71. },
  72. getData () {
  73. return getPxClassDataApi().then(res => {
  74. console.log(res)
  75. this.shopList = res.data.list
  76. }).catch(err => { console.log(err) })
  77. },
  78. editItem (id) {
  79. this.pageTo({
  80. url: '/pagesStatistics/trainingClassEdit?id=' + id,
  81. })
  82. },
  83. addItem () {
  84. this.pageTo({
  85. url: '/pagesStatistics/trainingClassEdit',
  86. })
  87. },
  88. delItem (id) {
  89. let that = this
  90. uni.showModal({
  91. content: '确定要删除吗?',
  92. success: function (res) {
  93. if (res.confirm) {
  94. pxClassDel({ id }).then(res => {
  95. that.shopList = [];
  96. uni.removeStorageSync('pxClassInfoList');
  97. that.getData()
  98. }).catch(err => { console.log(err) })
  99. } else if (res.cancel) {
  100. }
  101. }
  102. });
  103. }
  104. }
  105. };
  106. </script>
  107. <style lang="scss" scoped>
  108. .shop-page {
  109. // height: 100%;
  110. display: flex;
  111. flex-direction: column;
  112. background-color: #f9fbfc;
  113. .under-bar {
  114. position: fixed;
  115. bottom: 0;
  116. padding: 0 20upx;
  117. display: flex;
  118. flex-shrink: 0;
  119. justify-content: flex-end;
  120. align-items: center;
  121. width: 100%;
  122. height: 100upx;
  123. background-color: #fff;
  124. }
  125. .shop-list {
  126. margin-top: 20upx;
  127. flex: 1;
  128. padding-bottom: 100upx;
  129. .shop-item {
  130. margin-bottom: 20upx;
  131. padding: 30upx;
  132. display: flex;
  133. align-items: center;
  134. box-shadow: 0upx 1px 0upx 0upx #eeeeee;
  135. background-color: #fff;
  136. .avatar {
  137. width: 120upx;
  138. height: 120upx;
  139. image {
  140. width: 100%;
  141. height: 100%;
  142. background-color: #eee;
  143. }
  144. }
  145. .info {
  146. flex: 1;
  147. margin: 0 20upx;
  148. .info-name {
  149. font-size: 28upx;
  150. font-family: PingFang SC;
  151. font-weight: 400;
  152. color: #333333;
  153. }
  154. .info-address {
  155. margin-top: 15upx;
  156. font-size: 30upx;
  157. font-weight: 600;
  158. color: #333333;
  159. }
  160. }
  161. .edit {
  162. display: flex;
  163. align-items: center;
  164. justify-content: space-around;
  165. flex-shrink: 0;
  166. .iconfont {
  167. margin: 0 20upx;
  168. }
  169. .iconshoukuanma1 {
  170. font-size: 40upx;
  171. color: $mainColor;
  172. }
  173. .iconbianji {
  174. font-size: 40upx;
  175. }
  176. .iconshanchu1 {
  177. font-size: 40upx;
  178. }
  179. }
  180. }
  181. }
  182. }
  183. </style>