shopcarTemporary.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. <template>
  2. <view>
  3. <view style="padding: 10rpx 20rpx;">
  4. <view v-if="!shopDataNow">
  5. <image style="margin: 0 auto; width: 100%;" src="../../static/img/page/empty_view.png"></image>
  6. </view>
  7. <u-checkbox-group v-model="checkgroup" placement="column" @change="checkChange">
  8. <view v-for="(item, index) in shopDataNow" :key="index">
  9. <view v-if="item.num !== 0 && item.num" class="listItemStyle">
  10. <u-row>
  11. <u-col span="2">
  12. <view style="margin: 15rpx 10rpx 0 10rpx;">
  13. <u-checkbox activeColor="#53a591" :customStyle="{marginBottom: '8px'}" :name="item">
  14. </u-checkbox>
  15. </view>
  16. </u-col>
  17. <u-col span="3">
  18. <u--image :showLoading="true" shape="circle" :src="baseURL+item.giftPictrue"
  19. width="80px" height="80px" style="margin: 10rpx "></u--image>
  20. </u-col>
  21. <u-col span="7">
  22. <view style="">
  23. {{item.giftName}}
  24. </view>
  25. <u-row>
  26. <u-col span="6">
  27. <view style="margin-top: 10rpx;">
  28. <u-icon name="integral" :label="item.giftPrice"></u-icon>
  29. </view>
  30. </u-col>
  31. <u-col span="6">
  32. <view style="margin-top: 30rpx;">
  33. <u-row>
  34. <u-col span="4">
  35. <view style="padding: 5rpx;">
  36. <u-button icon="minus" size="mini" plain="ture"
  37. :disabled="buttonIsUse" @click="minusGoods(index,item)">
  38. </u-button>
  39. </view>
  40. </u-col>
  41. <u-col span="4">
  42. <view style="text-align: center;">
  43. {{parseInt(item.num)}}
  44. </view>
  45. </u-col>
  46. <u-col span="4">
  47. <view style="padding: 5rpx;">
  48. <u-button icon="plus" size="mini" plain="ture"
  49. :disabled="buttonIsUse" @click="addGoods(item)">
  50. </u-button>
  51. </view>
  52. </u-col>
  53. </u-row>
  54. </view>
  55. </u-col>
  56. </u-row>
  57. </u-col>
  58. </u-row>
  59. </view>
  60. </view>
  61. </u-checkbox-group>
  62. </view>
  63. <view style="margin-bottom: 150rpx;"></view>
  64. <view class="bottim_view">
  65. <view>
  66. <u-row>
  67. <u-col span="11">
  68. <u-button class="btnDoPay" shape="circle" @click="toOKPage"
  69. color="linear-gradient(to bottom right, #79a7a4, #88d8a1)" text="确认下单"></u-button>
  70. </u-col>
  71. </u-row>
  72. </view>
  73. </view>
  74. </view>
  75. </template>
  76. <script>
  77. export default {
  78. data() {
  79. return {
  80. status: 'loadmore',
  81. baseURL: this.$BASE_URL,
  82. list: 15,
  83. page: 0,
  84. shopDataNow: [],
  85. gwcId: '',
  86. buttonIsUse: false,
  87. checkgroup: ''
  88. }
  89. },
  90. onLoad() {
  91. this.getGWC()
  92. },
  93. onReachBottom() {
  94. if (this.page >= 3) return;
  95. this.status = 'loading';
  96. this.page = ++this.page;
  97. setTimeout(() => {
  98. this.list += 10;
  99. if (this.page >= 3) this.status = 'nomore';
  100. else this.status = 'loading';
  101. }, 2000)
  102. },
  103. methods: {
  104. checkChange(detail) {
  105. if (detail.length === 0) {
  106. this.buttonIsUse = false
  107. } else {
  108. this.buttonIsUse = true
  109. uni.setStorageSync('shopData', detail)
  110. }
  111. },
  112. getGWC() {
  113. this.shopDataNow = uni.getStorageSync('shopData')
  114. uni.removeStorageSync('shopData')
  115. uni.stopPullDownRefresh()
  116. },
  117. async minusGoods(index, data) {
  118. if (data.num === 1) {
  119. this.shopDataNow.splice(index, 1)
  120. } else {
  121. data.num -= 1
  122. }
  123. },
  124. async addGoods(data) {
  125. if (data.num < data.amount) {
  126. data.num += 1
  127. }
  128. },
  129. toOKPage() {
  130. let that = this
  131. let data = uni.getStorageSync('shopData')
  132. if (data && data.length > 0) {
  133. uni.navigateTo({
  134. url: 'list'
  135. })
  136. } else {
  137. uni.showToast({
  138. duration: 1500,
  139. title: '请选择至少一个物品',
  140. icon: 'none'
  141. })
  142. }
  143. }
  144. }
  145. }
  146. </script>
  147. <style lang="scss" scoped>
  148. .listItemStyle {
  149. height: 100%;
  150. margin: 10rpx 0;
  151. padding: 20rpx 15rpx;
  152. border-radius: 15px;
  153. background-color: #ffffff;
  154. border: 1rpx solid #eeeeee;
  155. }
  156. .wrap {
  157. padding: 24rpx;
  158. }
  159. .item {
  160. padding: 24rpx 0;
  161. color: $u-content-color;
  162. font-size: 28rpx;
  163. }
  164. .bottim_view {
  165. padding: 5px 20px 30px;
  166. position: fixed;
  167. left: 0px;
  168. bottom: 0px;
  169. width: 100%;
  170. height: 40px;
  171. background-color: #ffffff;
  172. z-index: 9999;
  173. }
  174. .btnDoPay {
  175. width: 100%;
  176. }
  177. </style>