index.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. <template>
  2. <view class="content">
  3. <view class="dyquan-wrap" v-for="(item,index) in list" :key="index">
  4. <view class="showtime flex">
  5. <text class="line2">{{ item.card_name|| '' }}</text>
  6. <text class="money">{{item.servicecard.card_price}}</text>
  7. </view>
  8. <view class="item-info" v-for="good in item.card" @click="goGoods(good)">
  9. <view class="img-box">
  10. <image class="tip" :src="good.product.image" mode=""></image>
  11. <view class="good-type" v-if="good.type==2">
  12. 月卡
  13. </view>
  14. </view>
  15. <view class="info-info" v-if="good.type==1">
  16. <view class="line2">
  17. {{good.product.store_name || ''}}
  18. </view>
  19. <view class="info-cs">
  20. <view>
  21. 原价:{{good.product.price|| ''}}
  22. </view>
  23. </view>
  24. <view class="info-cs">
  25. <view>
  26. 剩余:{{good.repertory || 0}}次
  27. </view>
  28. </view>
  29. </view>
  30. <view class="info-info" v-if="good.type==2">
  31. <view class="line2">
  32. {{good.product.store_name || ''}}
  33. </view>
  34. <view class="info-cs">
  35. <view>
  36. 原价:{{good.product.price|| ''}}
  37. </view>
  38. <view>
  39. 剩余:{{good.repertory || 0}}次
  40. </view>
  41. </view>
  42. <view class="info-cs">
  43. <view>
  44. {{good.end_time_text}}继续得{{good.month_repertory}}次
  45. </view>
  46. <view>
  47. {{good.card_end_time_text}}到期
  48. </view>
  49. </view>
  50. </view>
  51. </view>
  52. <view class="good-time">
  53. 购买时间:{{item.update_time}}
  54. </view>
  55. </view>
  56. <view v-if="list.length == 0 && loadingType=='nomore'">
  57. <emptyPage title="暂无订单信息~"></emptyPage>
  58. </view>
  59. </view>
  60. </template>
  61. <script>
  62. import {
  63. getMyServeList
  64. } from "@/api/user.js";
  65. import emptyPage from '@/components/emptyPage.vue';
  66. export default {
  67. components: {
  68. emptyPage
  69. },
  70. data() {
  71. return {
  72. page: 1,
  73. pageSize: 10,
  74. loaded: false,
  75. loadingType: 'more',
  76. list: []
  77. }
  78. },
  79. onLoad(opt) {
  80. },
  81. onShow() {
  82. this.getList()
  83. },
  84. onReachBottom() {
  85. this.getList()
  86. },
  87. onReady() {
  88. },
  89. methods: {
  90. goGoods(item) {
  91. console.log(item)
  92. uni.navigateTo({
  93. url: '/pages/goods_details/index?id=' + item.product_id
  94. })
  95. },
  96. tabClick(item, index) {
  97. this.tabCurrentIndex = index;
  98. },
  99. // 获取时间字符串
  100. getTimeText(res) {
  101. return (new Date(res*1000)).toLocaleString().split(" ")[0];
  102. },
  103. getList(type) {
  104. let that = this
  105. if (type == 'reload') {
  106. // item.list
  107. return
  108. }
  109. if (type == 'tab' && that.loaded) {
  110. return
  111. }
  112. if (that.loadingType == 'loading' || that.loadingType == 'nomore') {
  113. return
  114. }
  115. that.loadingType = 'loading'
  116. getMyServeList({
  117. page: that.page,
  118. limit: that.pageSize,
  119. name: ''
  120. }).then(({
  121. data
  122. }) => {
  123. let ar = data.list.map(
  124. (res) => {
  125. for (let i = 0; i < res.card.length; i++) {
  126. const car = res.card[i];
  127. if(car.type==2){
  128. car.card_end_time_text = that.getTimeText(car.card_end_time);
  129. car.card_start_time_text = that.getTimeText(car.card_start_time);
  130. car.end_time_text = that.getTimeText(car.end_time);
  131. car.start_time_text = that.getTimeText(car.start_time);
  132. }
  133. }
  134. return res
  135. }
  136. )
  137. that.list = that.list.concat(ar)
  138. that.page++
  139. if (data.length == that.pageSize) {
  140. that.loadingType = 'more'
  141. } else {
  142. that.loadingType = 'nomore'
  143. }
  144. })
  145. }
  146. }
  147. }
  148. </script>
  149. <style lang="scss">
  150. .content {
  151. background-color: #f8f6f6;
  152. height: auto;
  153. min-height: 100%;
  154. padding-top: 30rpx;
  155. }
  156. .dyquan-wrap {
  157. padding: 30rpx;
  158. background-color: #fff;
  159. margin: 0 30rpx;
  160. margin-bottom: 30rpx;
  161. border-radius: 20rpx;
  162. .good-time{
  163. margin-top: 20rpx;
  164. color:#999999;
  165. font-size: $uni-font-size-sm;
  166. }
  167. .showtime {
  168. padding-bottom: 20rpx;
  169. border-bottom: 1px solid #f8f6f6;
  170. font-size: 30rpx;
  171. font-weight: bold;
  172. justify-content: space-between;
  173. .money {
  174. flex-shrink: 0;
  175. color: $uni-color-warning;
  176. }
  177. }
  178. .item-info {
  179. display: flex;
  180. justify-content: flex-start;
  181. align-items: stretch;
  182. padding-top: 20rpx;
  183. .img-box{
  184. position: relative;
  185. .good-type{
  186. position: absolute;
  187. top: 0;
  188. left: 0;
  189. background-color: $uni-color-error;
  190. padding: 5rpx 20rpx;
  191. font-size: 20rpx;
  192. border-top-left-radius: 20rpx;
  193. border-bottom-right-radius: 20rpx;
  194. color: rgba(255, 255, 255, 0.7);
  195. }
  196. .tip {
  197. width: 160rpx;
  198. height: 160rpx;
  199. margin-right: 20rpx;
  200. border-radius: 20rpx;
  201. flex-shrink: 0;
  202. }
  203. }
  204. .info-info {
  205. font-size: 30rpx;
  206. font-weight: 500;
  207. color: #666666;
  208. display: flex;
  209. flex-direction: column;
  210. justify-content: space-between;
  211. align-items: stretch;
  212. flex-grow: 1;
  213. .info-cs {
  214. display: flex;
  215. justify-content: space-between;
  216. font-size: 26rpx;
  217. font-weight: 500;
  218. color: #999999;
  219. }
  220. }
  221. }
  222. }
  223. </style>