青蛙卖大米小程序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.

269 lines
5.0 KiB

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