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

414 lines
8.1 KiB

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
8 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
9 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
9 months ago
8 months ago
9 months ago
8 months ago
9 months ago
9 months ago
8 months ago
9 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
8 months ago
9 months ago
9 months ago
8 months ago
9 months ago
8 months ago
8 months ago
9 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
9 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
9 months ago
9 months ago
9 months ago
8 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
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
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
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
  1. <template>
  2. <view class="page">
  3. <navbar />
  4. <view class="user">
  5. <uv-checkbox-group shape="circle" v-model="checkboxValue">
  6. <uv-swipe-action>
  7. <view v-for="(item, index) in list.records" :key="index">
  8. <view style="margin-top: 20rpx;"></view>
  9. <uv-swipe-action-item :options="options" @click="delCart(item, index)">
  10. <view class="item">
  11. <view class="checkbox">
  12. <uv-checkbox :name="item.id" activeColor="#FA5A0A" size="40rpx"
  13. icon-size="35rpx"></uv-checkbox>
  14. </view>
  15. <image class="image"
  16. :src="item.pic || 'https://img95.699pic.com/photo/50058/1378.jpg_wh860.jpg'"
  17. mode=""></image>
  18. <view class="info">
  19. <view class="title">
  20. <view>{{ item.name }}</view>
  21. <view>
  22. <uv-number-box v-model="item.num"
  23. @change="e => valChange(item, e)"></uv-number-box>
  24. </view>
  25. </view>
  26. <!-- 规格下拉框 -->
  27. <view class="unit" @click="toggleDropdown">
  28. 规格{{ selectedOption || item.title }}
  29. <uv-icon name="arrow-down"></uv-icon>
  30. </view>
  31. <view class="price">
  32. <text>{{ item.price }}</text>
  33. </view>
  34. </view>
  35. </view>
  36. </uv-swipe-action-item>
  37. </view>
  38. </uv-swipe-action>
  39. </uv-checkbox-group>
  40. <view class="action">
  41. <view class="icon">
  42. <image src="/static/image/cart/1.png" mode=""></image>
  43. <view class="num">{{ checkboxValue.length }}</view>
  44. </view>
  45. <view class="price">
  46. <view class="count">
  47. 合计
  48. <view>
  49. <text>{{ totalPrice }}</text>
  50. </view>
  51. </view>
  52. <view class="text">
  53. {{ checkboxValue.length }}已享受更低优惠
  54. </view>
  55. </view>
  56. <view class="btn" @click="goCleaning">去结算</view>
  57. </view>
  58. </view>
  59. <!-- 地址弹框 -->
  60. <uv-popup ref="addressPopup" :round="30">
  61. <addressList ref="addressList" height="60vh" @select="selectAddress" />
  62. </uv-popup>
  63. <tabber select="3" />
  64. </view>
  65. </template>
  66. <script>
  67. import tabber from '@/components/base/tabbar.vue'
  68. import addressList from '@/components/address/addressList.vue'
  69. export default {
  70. components: {
  71. tabber,
  72. addressList,
  73. },
  74. data() {
  75. return {
  76. dropdownVisible: false,
  77. value: 0,
  78. checkboxValue: [],
  79. options: [{
  80. text: '删除',
  81. style: {
  82. backgroundColor: '#FA5A0A'
  83. }
  84. }],
  85. queryParams: {
  86. pageNo: 1,
  87. pageSize: 10,
  88. },
  89. list: [],
  90. addressTotal: 0,
  91. address: {
  92. name: '请选择联系人',
  93. addressDetail: ''
  94. },
  95. }
  96. },
  97. computed: {
  98. totalPrice() {
  99. if (!this.checkboxValue.length) {
  100. return 0
  101. }
  102. let price = 0
  103. this.list.records.forEach(n => {
  104. if (this.checkboxValue.includes(n.id)) {
  105. price += n.price * n.num
  106. }
  107. })
  108. return price
  109. },
  110. },
  111. onShow() {
  112. this.getData()
  113. this.getAddressListA()
  114. },
  115. //滚动到屏幕底部
  116. onReachBottom() {
  117. if (this.queryParams.pageSize < this.list.total) {
  118. this.queryParams.pageSize += 10
  119. this.getData()
  120. }
  121. },
  122. methods: {
  123. toggleDropdown() {
  124. this.dropdownVisible = !this.dropdownVisible
  125. },
  126. selectOption(option) {
  127. },
  128. // 去结算按钮
  129. goCleaning() {
  130. console.log("===");
  131. this.$refs.addressPopup.open('bottom')
  132. this.ordersPay()
  133. },
  134. // 多商品下单
  135. ordersPay() {
  136. let data = []
  137. console.log(this.address, "this.address");
  138. console.log(this.checkboxValue, "checkboxValue");
  139. for (var i = 0; i < this.list.length; i++) {
  140. if (this.checkboxValue.includes(this.list[i].id)) {
  141. data.push({
  142. id: this.list[i].id, //商品id
  143. skuId: this.unit.id, //规格id
  144. addressId: this.address.id, //地址id
  145. sku: this.unit.title, //规格
  146. num: this.list[i],
  147. })
  148. }
  149. }
  150. return
  151. this.$api('orderCreate', {
  152. req: JSON.stringify(data)
  153. }, res => {
  154. if (res.code == 200) {
  155. let form = {
  156. id: res.result.id
  157. }
  158. this.$api('orderPay', form, res => {
  159. if (res.code == 200) {
  160. uni.requestPayment({
  161. provider: 'wxpay', // 服务提提供商
  162. timeStamp: res.result.timeStamp, // 时间戳
  163. nonceStr: res.result.nonceStr, // 随机字符串
  164. package: res.result.packageValue,
  165. signType: res.result.signType, // 签名算法
  166. paySign: res.result.paySign, // 签名
  167. success: function(res) {
  168. // console.log('支付成功', res);
  169. uni.redirectTo({
  170. url: '/pages/index/order'
  171. })
  172. },
  173. fail: function(err) {
  174. console.log('支付失败', err);
  175. // self.$refs.confirmationPopup.close()
  176. uni.showToast({
  177. icon: 'none',
  178. title: "支付失败"
  179. })
  180. }
  181. });
  182. }
  183. })
  184. }
  185. })
  186. },
  187. // 修改购物车里面商品的规格
  188. unitChange(item, e) {
  189. // TODO 查询商品规格
  190. // this.$api('goodsOne', this.queryParams, res => {
  191. // if (res.code == 200) {
  192. // this.list = res.result
  193. // }
  194. // })
  195. },
  196. // 获取地址列表
  197. getAddressListA() {
  198. this.$refs.addressList.getAddressList().then(res => {
  199. this.addressTotal = res.total
  200. if (this.addressTotal != 0) {
  201. this.address = res.records[0]
  202. }
  203. })
  204. },
  205. // 选择地址
  206. selectAddress(e) {
  207. this.address = e
  208. this.$refs.addressPopup.close()
  209. },
  210. valChange(item, e) {
  211. console.log(e.value);
  212. this.$api('cartNum', {
  213. id: item.id,
  214. num: e.value,
  215. })
  216. },
  217. // 购物车分页
  218. getData() {
  219. this.$api('cartPage', this.queryParams, res => {
  220. if (res.code == 200) {
  221. this.list = res.result
  222. }
  223. })
  224. },
  225. // 删除购物车
  226. delCart(item, index) {
  227. this.$api('cartDel', {
  228. id: item.id
  229. }, res => {
  230. if (res.code == 200) {
  231. this.getData()
  232. uni.showToast({
  233. title: '删除成功',
  234. });
  235. }
  236. })
  237. },
  238. }
  239. }
  240. </script>
  241. <style scoped lang="scss">
  242. .page {
  243. /deep/ .uv-swipe-action {
  244. width: 100%;
  245. }
  246. }
  247. .user {
  248. .item {
  249. background-color: #fff;
  250. display: flex;
  251. padding: 30rpx;
  252. .checkbox {
  253. display: flex;
  254. justify-content: center;
  255. align-items: center;
  256. }
  257. .image {
  258. width: 200rpx;
  259. height: 200rpx;
  260. border-radius: 20rpx;
  261. }
  262. .info {
  263. flex: 1;
  264. .title {
  265. display: flex;
  266. padding: 10rpx 20rpx;
  267. justify-content: space-between;
  268. }
  269. .unit {
  270. font-size: 24rpx;
  271. padding: 10rpx 20rpx;
  272. color: #717171;
  273. display: flex;
  274. align-items: center;
  275. }
  276. .price {
  277. color: $uni-color;
  278. font-size: 28rpx;
  279. padding: 10rpx 20rpx;
  280. text {
  281. font-size: 36rpx;
  282. font-weight: 900;
  283. }
  284. }
  285. }
  286. }
  287. .action {
  288. width: 700rpx;
  289. position: fixed;
  290. bottom: 220rpx;
  291. left: 25rpx;
  292. background-color: #fff;
  293. height: 100rpx;
  294. border-radius: 50rpx;
  295. box-shadow: 0 0 6rpx 6rpx #00000010;
  296. display: flex;
  297. justify-content: center;
  298. align-items: center;
  299. overflow: hidden;
  300. .icon {
  301. position: relative;
  302. width: 80rpx;
  303. height: 80rpx;
  304. margin: 0 20rpx;
  305. image {
  306. width: 80rpx;
  307. height: 80rpx;
  308. }
  309. .num {
  310. position: absolute;
  311. right: 10rpx;
  312. top: 0rpx;
  313. background-color: $uni-color;
  314. color: #fff;
  315. font-size: 18rpx;
  316. border-radius: 50%;
  317. height: 30rpx;
  318. width: 30rpx;
  319. display: flex;
  320. justify-content: center;
  321. align-items: center;
  322. }
  323. }
  324. .price {
  325. .count {
  326. display: flex;
  327. font-size: 26rpx;
  328. align-items: center;
  329. view {
  330. color: $uni-color;
  331. margin-left: 10rpx;
  332. text {
  333. font-size: 32rpx;
  334. font-weight: 900;
  335. }
  336. }
  337. }
  338. .text {
  339. font-size: 20rpx;
  340. color: #717171;
  341. }
  342. }
  343. .btn {
  344. margin-left: auto;
  345. background-color: $uni-color;
  346. height: 100%;
  347. padding: 0 50rpx;
  348. color: #fff;
  349. display: flex;
  350. justify-content: center;
  351. align-items: center;
  352. }
  353. }
  354. }
  355. .example-body {
  356. padding: 12px;
  357. background-color: #FFFFFF;
  358. }
  359. .result-box {
  360. text-align: center;
  361. padding: 20px 0px;
  362. font-size: 16px;
  363. }
  364. </style>