shopcar.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. <template>
  2. <view class="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="70px" height="70px" 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: 10px;">
  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(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. uni.removeStorageSync('shopData')
  93. },
  94. onReachBottom() {
  95. if (this.page >= 3) return;
  96. this.status = 'loading';
  97. this.page = ++this.page;
  98. setTimeout(() => {
  99. this.list += 10;
  100. if (this.page >= 3) this.status = 'nomore';
  101. else this.status = 'loading';
  102. }, 2000)
  103. },
  104. methods: {
  105. checkChange(detail) {
  106. if (detail.length === 0) {
  107. this.buttonIsUse = false
  108. } else {
  109. this.buttonIsUse = true
  110. uni.setStorageSync('shopData', detail)
  111. }
  112. },
  113. async getGWC() {
  114. // 发送请求
  115. const {
  116. data: res
  117. } = await this.$httpRequest({
  118. url: '/app/getUsc',
  119. method: 'get',
  120. urlType: this.$getUrlType()
  121. });
  122. if (res.code === 200) {
  123. this.shopDataNow = res.data
  124. } else {
  125. uni.showToast({
  126. duration: 1000,
  127. title: res.msg,
  128. icon: 'none'
  129. })
  130. }
  131. uni.stopPullDownRefresh()
  132. },
  133. async minusGoods(data) {
  134. data.plusOrMinus = 1
  135. // 发送请求
  136. const {
  137. data: res
  138. } = await this.$httpRequest({
  139. url: '/app/addShopCar',
  140. method: 'post',
  141. data: data,
  142. urlType: this.$getUrlType()
  143. });
  144. if (res.code === 200) {
  145. this.getGWC()
  146. } else {
  147. this.$showModal(res.msg)
  148. }
  149. },
  150. async addGoods(data) {
  151. data.plusOrMinus = 0
  152. // 发送请求
  153. const {
  154. data: res
  155. } = await this.$httpRequest({
  156. url: '/app/addShopCar',
  157. method: 'post',
  158. data: data,
  159. urlType: this.$getUrlType()
  160. });
  161. if (res.code === 200) {
  162. this.getGWC()
  163. } else {
  164. this.$showModal(res.msg)
  165. }
  166. },
  167. toOKPage() {
  168. let that = this
  169. uni.requestSubscribeMessage({
  170. tmplIds: ['-57EtxA5K6MUpKbvQwHblrKldu5j1tG6-JlYZNpIZ04'],
  171. success(res) {
  172. let data = uni.getStorageSync('shopData')
  173. if (data && data.length > 0) {
  174. uni.navigateTo({
  175. url: 'list'
  176. })
  177. } else {
  178. uni.showToast({
  179. duration: 1500,
  180. title: '请选择至少一个物品',
  181. icon: 'none'
  182. })
  183. }
  184. }
  185. })
  186. }
  187. }
  188. }
  189. </script>
  190. <style lang="scss" scoped>
  191. .listItemStyle {
  192. height: 100%;
  193. margin: 10rpx 0;
  194. padding: 20rpx 15rpx;
  195. border-radius: 15px;
  196. background-color: #ffffff;
  197. border: 1rpx solid #eeeeee;
  198. }
  199. .wrap {
  200. padding: 24rpx;
  201. }
  202. .item {
  203. padding: 24rpx 0;
  204. color: $u-content-color;
  205. font-size: 28rpx;
  206. }
  207. .bottim_view {
  208. padding: 5px 20px 30px;
  209. position: fixed;
  210. left: 0px;
  211. bottom: 0px;
  212. width: 100%;
  213. height: 40px;
  214. background-color: #ffffff;
  215. z-index: 9999;
  216. }
  217. .btnDoPay {
  218. width: 100%;
  219. }
  220. </style>