酒店桌布为微信小程序
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.

282 lines
5.3 KiB

10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 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.records"
  11. :key="index">
  12. <view style="margin-top: 20rpx;"></view>
  13. <uv-swipe-action-item
  14. :options="options"
  15. @click="delCart(item, index)">
  16. <view class="item">
  17. <view class="checkbox">
  18. <uv-checkbox
  19. :name="item.id"
  20. activeColor="#FA5A0A"
  21. size="40rpx"
  22. icon-size="35rpx"
  23. ></uv-checkbox>
  24. </view>
  25. <image
  26. class="image"
  27. :src="item.pic || 'https://img95.699pic.com/photo/50058/1378.jpg_wh860.jpg'"
  28. mode=""></image>
  29. <view class="info">
  30. <view class="title">
  31. <view class="">
  32. {{ item.name }}
  33. </view>
  34. <view class="">
  35. <uv-number-box v-model="item.num"
  36. @change="e => valChange(item, e)"></uv-number-box>
  37. </view>
  38. </view>
  39. <view class="unit">
  40. 规格{{ item.title }}
  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. 去结算
  72. </view>
  73. </view>
  74. </view>
  75. <tabber select="3" />
  76. </view>
  77. </template>
  78. <script>
  79. import tabber from '@/components/base/tabbar.vue'
  80. export default {
  81. components: {
  82. tabber,
  83. },
  84. data() {
  85. return {
  86. value : 0,
  87. checkboxValue : [],
  88. options: [
  89. {
  90. text: '删除',
  91. style: {
  92. backgroundColor: '#FA5A0A'
  93. }
  94. },
  95. ],
  96. queryParams: {
  97. pageNo: 1,
  98. pageSize: 10
  99. },
  100. list : [],
  101. }
  102. },
  103. computed: {
  104. totalPrice(){
  105. if (!this.checkboxValue.length) {
  106. return 0
  107. }
  108. let price = 0
  109. this.list.records.forEach(n => {
  110. if(this.checkboxValue.includes(n.id)){
  111. price += n.price * n.num
  112. }
  113. })
  114. return price
  115. },
  116. },
  117. onShow() {
  118. this.getData()
  119. },
  120. //滚动到屏幕底部
  121. onReachBottom() {
  122. if(this.queryParams.pageSize < this.list.total){
  123. this.queryParams.pageSize += 10
  124. this.getData()
  125. }
  126. },
  127. methods: {
  128. valChange(item, e){
  129. console.log(e.value);
  130. this.$api('cartNum', {
  131. id : item.id,
  132. num : e.value,
  133. })
  134. },
  135. // 购物车分页
  136. getData(){
  137. this.$api('cartPage', this.queryParams, res => {
  138. if(res.code == 200){
  139. this.list = res.result
  140. }
  141. })
  142. },
  143. // 删除购物车
  144. delCart(item, index){
  145. this.$api('cartDel', {
  146. id : item.id
  147. }, res => {
  148. if(res.code == 200){
  149. this.getData()
  150. uni.showToast({
  151. title: '删除成功',
  152. });
  153. }
  154. })
  155. },
  156. }
  157. }
  158. </script>
  159. <style scoped lang="scss">
  160. .page {
  161. /deep/ .uv-swipe-action{
  162. width: 100%;
  163. }
  164. }
  165. .user {
  166. .item{
  167. background-color: #fff;
  168. display: flex;
  169. padding: 30rpx;
  170. .checkbox{
  171. display: flex;
  172. justify-content: center;
  173. align-items: center;
  174. }
  175. .image{
  176. width: 200rpx;
  177. height: 200rpx;
  178. border-radius: 20rpx;
  179. }
  180. .info{
  181. flex: 1;
  182. .title{
  183. display: flex;
  184. padding: 10rpx 20rpx;
  185. justify-content: space-between;
  186. }
  187. .unit{
  188. font-size: 24rpx;
  189. padding: 10rpx 20rpx;
  190. color: #717171;
  191. display: flex;
  192. align-items: center;
  193. }
  194. .price{
  195. color: $uni-color;
  196. font-size: 28rpx;
  197. padding: 10rpx 20rpx;
  198. text{
  199. font-size: 36rpx;
  200. font-weight: 900;
  201. }
  202. }
  203. }
  204. }
  205. .action{
  206. width: 700rpx;
  207. position: fixed;
  208. bottom: 220rpx;
  209. left: 25rpx;
  210. background-color: #fff;
  211. height: 100rpx;
  212. border-radius: 50rpx;
  213. box-shadow: 0 0 6rpx 6rpx #00000010;
  214. display: flex;
  215. justify-content: center;
  216. align-items: center;
  217. overflow: hidden;
  218. .icon{
  219. position: relative;
  220. width: 80rpx;
  221. height: 80rpx;
  222. margin: 0 20rpx;
  223. image{
  224. width: 80rpx;
  225. height: 80rpx;
  226. }
  227. .num{
  228. position: absolute;
  229. right: 10rpx;
  230. top: 0rpx;
  231. background-color: $uni-color;
  232. color: #fff;
  233. font-size: 18rpx;
  234. border-radius: 50%;
  235. height: 30rpx;
  236. width: 30rpx;
  237. display: flex;
  238. justify-content: center;
  239. align-items: center;
  240. }
  241. }
  242. .price{
  243. .count{
  244. display: flex;
  245. font-size: 26rpx;
  246. align-items: center;
  247. view{
  248. color: $uni-color;
  249. margin-left: 10rpx;
  250. text{
  251. font-size: 32rpx;
  252. font-weight: 900;
  253. }
  254. }
  255. }
  256. .text{
  257. font-size: 20rpx;
  258. color: #717171;
  259. }
  260. }
  261. .btn{
  262. margin-left: auto;
  263. background-color: $uni-color;
  264. height: 100%;
  265. padding: 0 50rpx;
  266. color: #fff;
  267. display: flex;
  268. justify-content: center;
  269. align-items: center;
  270. }
  271. }
  272. }
  273. </style>