shopcar.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  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. <view style="text-align: left;color: #ffaf25;font-size: 22rpx;margin-top: 10rpx;">
  26. {{item.eventTime+" 可领取"}}
  27. </view>
  28. <u-row>
  29. <u-col span="6">
  30. <view style="margin-top: 10rpx;">
  31. <u-icon name="integral" :label="item.giftPrice"></u-icon>
  32. </view>
  33. </u-col>
  34. <u-col span="6">
  35. <view style="margin-top: 30rpx;">
  36. <u-row>
  37. <u-col span="4">
  38. <view style="padding: 5rpx;">
  39. <u-button icon="minus" size="mini" plain="ture"
  40. :disabled="buttonIsUse" @click="minusGoods(item)">
  41. </u-button>
  42. </view>
  43. </u-col>
  44. <u-col span="4">
  45. <view style="text-align: center;">
  46. {{parseInt(item.num)}}
  47. </view>
  48. </u-col>
  49. <u-col span="4">
  50. <view style="padding: 5rpx;">
  51. <u-button icon="plus" size="mini" plain="ture"
  52. :disabled="buttonIsUse" @click="addGoods(item)">
  53. </u-button>
  54. </view>
  55. </u-col>
  56. </u-row>
  57. </view>
  58. </u-col>
  59. </u-row>
  60. </u-col>
  61. </u-row>
  62. </view>
  63. </view>
  64. </u-checkbox-group>
  65. </view>
  66. <view style="margin-bottom: 150rpx;"></view>
  67. <view class="bottim_view">
  68. <view>
  69. <u-row>
  70. <u-col span="11">
  71. <u-button class="btnDoPay" shape="circle" @click="toOKPage"
  72. color="linear-gradient(to bottom right, #79a7a4, #88d8a1)" text="确认下单"></u-button>
  73. </u-col>
  74. </u-row>
  75. </view>
  76. </view>
  77. </view>
  78. </template>
  79. <script>
  80. export default {
  81. data() {
  82. return {
  83. status: 'loadmore',
  84. baseURL: this.$BASE_URL,
  85. list: 15,
  86. page: 0,
  87. shopDataNow: [],
  88. gwcId: '',
  89. buttonIsUse: false,
  90. checkgroup: ''
  91. }
  92. },
  93. onLoad() {
  94. this.getGWC()
  95. uni.removeStorageSync('shopData')
  96. },
  97. onReachBottom() {
  98. if (this.page >= 3) return;
  99. this.status = 'loading';
  100. this.page = ++this.page;
  101. setTimeout(() => {
  102. this.list += 10;
  103. if (this.page >= 3) this.status = 'nomore';
  104. else this.status = 'loading';
  105. }, 2000)
  106. },
  107. methods: {
  108. checkChange(detail) {
  109. if (detail.length === 0) {
  110. this.buttonIsUse = false
  111. } else {
  112. this.buttonIsUse = true
  113. uni.setStorageSync('shopData', detail)
  114. }
  115. },
  116. async getGWC() {
  117. // 发送请求
  118. const {
  119. data: res
  120. } = await this.$httpRequest({
  121. url: '/app/getUsc',
  122. method: 'get',
  123. urlType: this.$getUrlType()
  124. });
  125. if (res.code === 200) {
  126. this.shopDataNow = res.data
  127. } else {
  128. uni.showToast({
  129. duration: 1000,
  130. title: res.msg,
  131. icon: 'none'
  132. })
  133. }
  134. uni.stopPullDownRefresh()
  135. },
  136. async minusGoods(data) {
  137. data.plusOrMinus = 1
  138. // 发送请求
  139. const {
  140. data: res
  141. } = await this.$httpRequest({
  142. url: '/app/addShopCar',
  143. method: 'post',
  144. data: data,
  145. urlType: this.$getUrlType()
  146. });
  147. if (res.code === 200) {
  148. this.getGWC()
  149. } else {
  150. this.$showModal(res.msg)
  151. }
  152. },
  153. async addGoods(data) {
  154. data.plusOrMinus = 0
  155. // 发送请求
  156. const {
  157. data: res
  158. } = await this.$httpRequest({
  159. url: '/app/addShopCar',
  160. method: 'post',
  161. data: data,
  162. urlType: this.$getUrlType()
  163. });
  164. if (res.code === 200) {
  165. this.getGWC()
  166. } else {
  167. this.$showModal(res.msg)
  168. }
  169. },
  170. toOKPage() {
  171. let that = this
  172. let data = uni.getStorageSync('shopData')
  173. if (data && data.length > 0) {
  174. for (var i = 0; i < data.length; i++) {
  175. for (var j = 0; j < data.length - 1; j++) {
  176. if (data[i].eventId !== data[j + 1].eventId) {
  177. that.$showModal("不同活动商品不能同时下单")
  178. return;
  179. }
  180. }
  181. }
  182. uni.navigateTo({
  183. url: 'list'
  184. })
  185. } else {
  186. uni.showToast({
  187. duration: 1500,
  188. title: '请选择至少一个物品',
  189. icon: 'none'
  190. })
  191. }
  192. }
  193. }
  194. }
  195. </script>
  196. <style lang="scss" scoped>
  197. .listItemStyle {
  198. height: 100%;
  199. margin: 10rpx 0;
  200. padding: 20rpx 15rpx;
  201. border-radius: 15px;
  202. background-color: #ffffff;
  203. border: 1rpx solid #eeeeee;
  204. }
  205. .wrap {
  206. padding: 24rpx;
  207. }
  208. .item {
  209. padding: 24rpx 0;
  210. color: $u-content-color;
  211. font-size: 28rpx;
  212. }
  213. .bottim_view {
  214. padding: 5px 20px 30px;
  215. position: fixed;
  216. left: 0px;
  217. bottom: 0px;
  218. width: 100%;
  219. height: 40px;
  220. background-color: #ffffff;
  221. z-index: 9999;
  222. }
  223. .btnDoPay {
  224. width: 100%;
  225. }
  226. </style>