青蛙卖大米小程序2024-11-24
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

296 lines
5.6 KiB

5 months ago
4 months ago
5 months ago
4 months ago
5 months ago
4 months ago
5 months ago
4 months ago
5 months ago
4 months ago
4 months ago
5 months ago
4 months ago
4 months ago
4 months ago
5 months ago
4 months ago
5 months ago
4 months ago
5 months ago
4 months ago
5 months ago
5 months ago
5 months ago
4 months ago
5 months ago
4 months ago
5 months ago
4 months ago
5 months ago
4 months ago
5 months ago
4 months ago
5 months ago
4 months ago
4 months ago
5 months ago
4 months ago
5 months ago
  1. <template>
  2. <view class="page">
  3. <navbar/>
  4. <view class="user">
  5. <uv-checkbox-group
  6. shape="circle"
  7. v-model="checkboxValue">
  8. <uv-swipe-action>
  9. <view
  10. v-for="(item, index) in list"
  11. :key="item.id">
  12. <view style="margin-top: 20rpx;"></view>
  13. <uv-swipe-action-item
  14. @click="e => deleteCart(e, item)"
  15. :options="options">
  16. <view class="item">
  17. <view class="checkbox">
  18. <uv-checkbox
  19. :name="item.id"
  20. activeColor="#A3D250"
  21. size="40rpx"
  22. icon-size="35rpx"
  23. ></uv-checkbox>
  24. </view>
  25. <image
  26. class="image"
  27. :src="item.image &&
  28. item.image.split(',')[0]"
  29. mode=""></image>
  30. <view class="info">
  31. <view class="title">
  32. <view class="">
  33. {{ item.title }}
  34. </view>
  35. </view>
  36. <view class="unit">
  37. 规格{{ item.sku }}
  38. <!-- <uv-icon name="arrow-down"></uv-icon> -->
  39. </view>
  40. <view
  41. style="display: flex;
  42. justify-content: space-between;
  43. align-items: center;">
  44. <view class="price">
  45. <text>{{ item.price }}</text>
  46. </view>
  47. <view class="">
  48. <uv-number-box v-model="item.num"
  49. @change="e => valChange(item, e)"></uv-number-box>
  50. </view>
  51. </view>
  52. </view>
  53. </view>
  54. </uv-swipe-action-item>
  55. </view>
  56. </uv-swipe-action>
  57. </uv-checkbox-group>
  58. <uv-empty
  59. v-if="list.length == 0"
  60. text="空空如也"
  61. textSize="30rpx"
  62. iconSize="200rpx"
  63. icon="list"></uv-empty>
  64. <view class="action">
  65. <view class="icon">
  66. <image src="/static/image/cart/1.png" mode=""></image>
  67. <view class="num">
  68. {{ checkboxValue.length }}
  69. </view>
  70. </view>
  71. <view class="price">
  72. <view class="count">
  73. 合计
  74. <view class="">
  75. <text>{{ totalPrice }}</text>
  76. </view>
  77. </view>
  78. <view class="text">
  79. {{ checkboxValue.length }}已享受更低优惠
  80. </view>
  81. </view>
  82. <view class="btn"
  83. @click="submit">
  84. 去结算
  85. </view>
  86. </view>
  87. </view>
  88. <tabber select="cart" />
  89. </view>
  90. </template>
  91. <script>
  92. import tabber from '@/components/base/tabbar.vue'
  93. import mixinsList from '@/mixins/list.js'
  94. export default {
  95. mixins : [mixinsList],
  96. components: {
  97. tabber,
  98. },
  99. data() {
  100. return {
  101. value : 0,
  102. checkboxValue : [],
  103. options: [
  104. {
  105. text: '删除',
  106. style: {
  107. backgroundColor: '#f40'
  108. }
  109. },
  110. ],
  111. mixinsListApi : 'getCartPageList',
  112. }
  113. },
  114. computed: {
  115. totalPrice(){
  116. if (!this.checkboxValue.length) {
  117. return 0
  118. }
  119. let price = 0
  120. this.list.forEach(n => {
  121. if(this.checkboxValue.includes(n.id)){
  122. price += n.price * n.num
  123. }
  124. })
  125. return price
  126. },
  127. },
  128. methods: {
  129. valChange(item, e) {
  130. this.$api('updateCartNum', {
  131. id: item.id,
  132. num: e.value,
  133. })
  134. },
  135. // 立即下单
  136. submit(){
  137. if(this.checkboxValue.length == 0){
  138. uni.showToast({
  139. title: '请选择商品',
  140. icon: 'none',
  141. })
  142. return
  143. }
  144. let arr = []
  145. this.list.forEach(n => {
  146. if(this.checkboxValue.includes(n.id)){
  147. arr.push(n)
  148. }
  149. })
  150. this.$store.commit('setPayOrderProduct', arr)
  151. this.$utils.navigateTo('/pages_order/order/createOrder')
  152. },
  153. deleteCart(e, item){
  154. this.$api('deleteCart', {
  155. id : item.id
  156. }, res => {
  157. this.getData()
  158. })
  159. },
  160. }
  161. }
  162. </script>
  163. <style scoped lang="scss">
  164. .page {
  165. padding-bottom: 200rpx;
  166. /deep/ .uv-swipe-action{
  167. width: 100%;
  168. }
  169. }
  170. .user {
  171. .item{
  172. background-color: #fff;
  173. display: flex;
  174. padding: 30rpx;
  175. .checkbox{
  176. display: flex;
  177. justify-content: center;
  178. align-items: center;
  179. }
  180. .image{
  181. width: 200rpx;
  182. height: 200rpx;
  183. border-radius: 20rpx;
  184. }
  185. .info{
  186. flex: 1;
  187. .title{
  188. display: flex;
  189. padding: 10rpx 20rpx;
  190. justify-content: space-between;
  191. }
  192. .unit{
  193. font-size: 24rpx;
  194. padding: 10rpx 20rpx;
  195. color: #717171;
  196. display: flex;
  197. align-items: center;
  198. }
  199. .price{
  200. color: $uni-color;
  201. font-size: 28rpx;
  202. padding: 10rpx 20rpx;
  203. text{
  204. font-size: 36rpx;
  205. font-weight: 900;
  206. }
  207. }
  208. }
  209. }
  210. .action{
  211. width: 700rpx;
  212. position: fixed;
  213. bottom: 220rpx;
  214. left: 25rpx;
  215. background-color: #fff;
  216. height: 100rpx;
  217. border-radius: 50rpx;
  218. box-shadow: 0 0 6rpx 6rpx #00000010;
  219. display: flex;
  220. justify-content: center;
  221. align-items: center;
  222. overflow: hidden;
  223. z-index: 999;
  224. .icon{
  225. position: relative;
  226. width: 80rpx;
  227. height: 80rpx;
  228. margin: 0 20rpx;
  229. image{
  230. width: 80rpx;
  231. height: 80rpx;
  232. }
  233. .num{
  234. position: absolute;
  235. right: 10rpx;
  236. top: 0rpx;
  237. background-color: $uni-color;
  238. color: #fff;
  239. font-size: 18rpx;
  240. border-radius: 50%;
  241. height: 30rpx;
  242. width: 30rpx;
  243. display: flex;
  244. justify-content: center;
  245. align-items: center;
  246. }
  247. }
  248. .price{
  249. .count{
  250. display: flex;
  251. font-size: 26rpx;
  252. align-items: center;
  253. view{
  254. color: $uni-color;
  255. margin-left: 10rpx;
  256. text{
  257. font-size: 32rpx;
  258. font-weight: 900;
  259. }
  260. }
  261. }
  262. .text{
  263. font-size: 20rpx;
  264. color: #717171;
  265. }
  266. }
  267. .btn{
  268. margin-left: auto;
  269. background-color: $uni-color;
  270. height: 100%;
  271. padding: 0 50rpx;
  272. color: #fff;
  273. display: flex;
  274. justify-content: center;
  275. align-items: center;
  276. }
  277. }
  278. }
  279. </style>