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

286 lines
5.4 KiB

9 months ago
9 months ago
9 months ago
8 months ago
9 months ago
8 months ago
9 months ago
8 months ago
9 months ago
8 months ago
9 months ago
8 months ago
9 months ago
9 months ago
9 months ago
8 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
8 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
8 months ago
9 months ago
9 months ago
8 months ago
9 months ago
8 months ago
9 months ago
8 months ago
8 months ago
8 months ago
9 months ago
9 months ago
9 months ago
8 months ago
9 months ago
9 months ago
9 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" @click="goCleaning">
  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. goCleaning(){
  137. },
  138. // 购物车分页
  139. getData(){
  140. this.$api('cartPage', this.queryParams, res => {
  141. if(res.code == 200){
  142. this.list = res.result
  143. }
  144. })
  145. },
  146. // 删除购物车
  147. delCart(item, index){
  148. this.$api('cartDel', {
  149. id : item.id
  150. }, res => {
  151. if(res.code == 200){
  152. this.getData()
  153. uni.showToast({
  154. title: '删除成功',
  155. });
  156. }
  157. })
  158. },
  159. }
  160. }
  161. </script>
  162. <style scoped lang="scss">
  163. .page {
  164. /deep/ .uv-swipe-action{
  165. width: 100%;
  166. }
  167. }
  168. .user {
  169. .item{
  170. background-color: #fff;
  171. display: flex;
  172. padding: 30rpx;
  173. .checkbox{
  174. display: flex;
  175. justify-content: center;
  176. align-items: center;
  177. }
  178. .image{
  179. width: 200rpx;
  180. height: 200rpx;
  181. border-radius: 20rpx;
  182. }
  183. .info{
  184. flex: 1;
  185. .title{
  186. display: flex;
  187. padding: 10rpx 20rpx;
  188. justify-content: space-between;
  189. }
  190. .unit{
  191. font-size: 24rpx;
  192. padding: 10rpx 20rpx;
  193. color: #717171;
  194. display: flex;
  195. align-items: center;
  196. }
  197. .price{
  198. color: $uni-color;
  199. font-size: 28rpx;
  200. padding: 10rpx 20rpx;
  201. text{
  202. font-size: 36rpx;
  203. font-weight: 900;
  204. }
  205. }
  206. }
  207. }
  208. .action{
  209. width: 700rpx;
  210. position: fixed;
  211. bottom: 220rpx;
  212. left: 25rpx;
  213. background-color: #fff;
  214. height: 100rpx;
  215. border-radius: 50rpx;
  216. box-shadow: 0 0 6rpx 6rpx #00000010;
  217. display: flex;
  218. justify-content: center;
  219. align-items: center;
  220. overflow: hidden;
  221. .icon{
  222. position: relative;
  223. width: 80rpx;
  224. height: 80rpx;
  225. margin: 0 20rpx;
  226. image{
  227. width: 80rpx;
  228. height: 80rpx;
  229. }
  230. .num{
  231. position: absolute;
  232. right: 10rpx;
  233. top: 0rpx;
  234. background-color: $uni-color;
  235. color: #fff;
  236. font-size: 18rpx;
  237. border-radius: 50%;
  238. height: 30rpx;
  239. width: 30rpx;
  240. display: flex;
  241. justify-content: center;
  242. align-items: center;
  243. }
  244. }
  245. .price{
  246. .count{
  247. display: flex;
  248. font-size: 26rpx;
  249. align-items: center;
  250. view{
  251. color: $uni-color;
  252. margin-left: 10rpx;
  253. text{
  254. font-size: 32rpx;
  255. font-weight: 900;
  256. }
  257. }
  258. }
  259. .text{
  260. font-size: 20rpx;
  261. color: #717171;
  262. }
  263. }
  264. .btn{
  265. margin-left: auto;
  266. background-color: $uni-color;
  267. height: 100%;
  268. padding: 0 50rpx;
  269. color: #fff;
  270. display: flex;
  271. justify-content: center;
  272. align-items: center;
  273. }
  274. }
  275. }
  276. </style>