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

470 lines
9.3 KiB

5 months ago
4 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
4 months ago
5 months ago
4 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
5 months ago
5 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
5 months ago
4 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
4 months ago
5 months ago
5 months ago
5 months ago
4 months ago
5 months ago
5 months ago
5 months ago
4 months ago
5 months ago
5 months ago
5 months ago
5 months ago
4 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
4 months ago
5 months ago
5 months ago
5 months ago
4 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
4 months ago
4 months ago
4 months ago
4 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
4 months ago
5 months ago
5 months ago
5 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
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
4 months ago
5 months ago
4 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
  1. <template>
  2. <uv-popup ref="popup" :round="30"
  3. @change="$refs.couponPopup.close()"
  4. bgColor="#f7f7f7">
  5. <view class="content">
  6. <!-- 地址 -->
  7. <view class="address" @click="openAddress">
  8. <image src="/static/image/address/selectIcon.png" mode=""></image>
  9. <view class="">
  10. {{ address.name }}
  11. </view>
  12. <view class="">
  13. {{ address.addressDetail }}
  14. </view>
  15. <view class="icon">
  16. <uv-icon size="30rpx" name="arrow-right"></uv-icon>
  17. </view>
  18. </view>
  19. <!-- 商品信息和数量 -->
  20. <view class="submit-info">
  21. <view class="title">
  22. 桌布租赁
  23. </view>
  24. <view class="box">
  25. <image class="image" :src="unit.pic" mode=""></image>
  26. <view class="info">
  27. <view class="price">
  28. <text>{{ detail.depositPrice }}</text>
  29. </view>
  30. <view class="unit">
  31. 请选择规格
  32. </view>
  33. <view class="">
  34. <uv-number-box
  35. @change="valChange"
  36. v-model="num"></uv-number-box>
  37. </view>
  38. </view>
  39. </view>
  40. </view>
  41. <!-- 规格 -->
  42. <view class="submit-unit">
  43. <view class="title">
  44. 规格选择
  45. </view>
  46. <view class="list">
  47. <view :class="{act : unitIndex == index}" v-for="(item, index) in detail.hotelGoodsSkuList"
  48. @click="selectUnit(item, index)" :key="index">
  49. {{ item.title }}
  50. </view>
  51. </view>
  52. </view>
  53. <!-- 优惠劵 -->
  54. <!-- <view style="padding: 0 20rpx;">
  55. <uv-cell
  56. icon="coupon"
  57. title="优惠劵"
  58. iconStyle="font-size: 34rpx;"
  59. rightIconStyle="font-size: 34rpx;"
  60. :value="couponText"
  61. @click="$refs.couponPopup.open('bottom')"
  62. isLink>
  63. </uv-cell>
  64. </view> -->
  65. <!-- 费用明细 -->
  66. <view class="expense-detail">
  67. <view class="title">
  68. 费用明细
  69. </view>
  70. <view class="detail" v-if="detail.depositPrice">
  71. <view>
  72. 应付款{{ price }}
  73. </view>
  74. <view>
  75. 押金{{ price }}
  76. </view>
  77. <view v-if="coupon.couponCondition <= price">
  78. 优惠-{{ coupon.couponPrice }}
  79. </view>
  80. <view v-if="coupon.couponCondition <= price">
  81. 实付款{{ (price - coupon.couponPrice).toFixed(2) }}
  82. </view>
  83. </view>
  84. <uv-cell
  85. icon="coupon"
  86. title="优惠"
  87. iconStyle="font-size: 34rpx;"
  88. rightIconStyle="font-size: 34rpx;">
  89. <template #value>
  90. <view class="coupon">
  91. {{ coupon.couponCondition }}立减{{ coupon.couponPrice }}
  92. </view>
  93. </template>
  94. </uv-cell>
  95. </view>
  96. <!-- 提交按钮 -->
  97. <view class="submit-btn">
  98. <view class="l" @click="addCart">
  99. 加入租赁车
  100. </view>
  101. <view class="r" @click="orderPay">
  102. {{ submiitTitle }}
  103. </view>
  104. </view>
  105. </view>
  106. <uv-popup ref="couponPopup" :round="30">
  107. <couponList
  108. ref="couponList"
  109. height="60vh"
  110. :depositPrice="price"
  111. @select="selectCoupon" />
  112. </uv-popup>
  113. <uv-popup ref="addressPopup" :round="30">
  114. <addressList ref="addressList" height="60vh" @select="selectAddress" />
  115. </uv-popup>
  116. </uv-popup>
  117. </template>
  118. <script>
  119. import addressList from '@/components/address/addressList.vue'
  120. import couponList from '@/components/user/couponList.vue'
  121. export default {
  122. components: {
  123. addressList,
  124. couponList,
  125. },
  126. props: {
  127. submiitTitle: {
  128. default: '立即租赁',
  129. type: String,
  130. },
  131. detail: {
  132. default: {}
  133. },
  134. },
  135. computed : {
  136. price(){
  137. return (this.detail.depositPrice * this.num).toFixed(2)
  138. }
  139. },
  140. data() {
  141. return {
  142. unitIndex: 0,
  143. address: {
  144. name: '请选择联系人',
  145. addressDetail: '',
  146. },
  147. num: 1,
  148. unit: {},
  149. addressTotal: 0,
  150. coupon : {
  151. price : 0,
  152. },
  153. couponText : '请选择',
  154. }
  155. },
  156. methods: {
  157. // 打开
  158. open() {
  159. this.$refs.popup.open('bottom')
  160. // this.$refs.couponList.getData()
  161. this.confCoupon()
  162. if (!this.unit.id) {
  163. this.selectUnit(this.detail.hotelGoodsSkuList[0], 0)
  164. }
  165. // 获取地址列表
  166. this.$refs.addressList.getAddressList().then(res => {
  167. this.addressTotal = res.total
  168. if (this.addressTotal != 0) {
  169. this.address = res.records[0]
  170. }
  171. })
  172. },
  173. confCoupon(){
  174. this.$api('confCoupon', res => {
  175. if(res.code == 200){
  176. this.coupon = res.result
  177. }
  178. })
  179. },
  180. valChange(){
  181. // this.coupon = {
  182. // price : 0,
  183. // }
  184. // this.couponText = '请选择'
  185. },
  186. // 选择优惠劵
  187. selectCoupon(e){
  188. this.couponText = e.couponName
  189. this.coupon = e
  190. this.$refs.couponPopup.close()
  191. },
  192. // 关闭
  193. close() {
  194. this.$refs.popup.close()
  195. },
  196. // 打开选择地址
  197. openAddress() {
  198. if (this.addressTotal == 0) {
  199. this.$refs.popup.close()
  200. return uni.navigateTo({
  201. url: '/pages_order/mine/address?type=back'
  202. })
  203. }
  204. this.$refs.addressPopup.open('bottom')
  205. },
  206. // 选择地址
  207. selectAddress(e) {
  208. this.address = e
  209. this.$refs.addressPopup.close()
  210. },
  211. // 选择规格
  212. selectUnit(item, index) {
  213. this.unit = item
  214. this.unitIndex = index
  215. },
  216. addCart() {
  217. this.$api('cartAdd', {
  218. id: this.detail.id,
  219. skuId: this.unit.id,
  220. num : this.num,
  221. }, res => {
  222. if (res.code == 200) {
  223. uni.showToast({
  224. title: '添加成功',
  225. });
  226. this.$refs.popup.close()
  227. }
  228. })
  229. },
  230. orderPay() {
  231. let data = [
  232. {
  233. id: this.detail.id, //商品id
  234. skuId: this.unit.id, //规格id
  235. addressId: this.address.id, //地址id
  236. sku: this.unit.title, //规格
  237. num: this.num,
  238. }
  239. ]
  240. if (this.$utils.verificationAll(data[0], {
  241. skuId: '请选择规格',
  242. addressId: '请选择地址',
  243. })) {
  244. return
  245. }
  246. this.$api('orderCreate', {req:JSON.stringify(data)}, res => {
  247. if (res.code == 200) {
  248. let form = {
  249. id: res.result.id,
  250. }
  251. if(this.coupon.id){
  252. form.couponId = this.coupon.id
  253. }
  254. this.$api('orderPay', form, res => {
  255. if (res.code == 200) {
  256. uni.requestPayment({
  257. provider: 'wxpay', // 服务提提供商
  258. timeStamp: res.result.timeStamp, // 时间戳
  259. nonceStr: res.result.nonceStr, // 随机字符串
  260. package: res.result.packageValue,
  261. signType: res.result.signType, // 签名算法
  262. paySign: res.result.paySign, // 签名
  263. success: function(res) {
  264. // console.log('支付成功', res);
  265. uni.redirectTo({
  266. url: '/pages/index/order'
  267. })
  268. },
  269. fail: function(err) {
  270. console.log('支付失败', err);
  271. uni.redirectTo({
  272. url:'/pages/index/order'
  273. })
  274. // self.$refs.confirmationPopup.close()
  275. uni.showToast({
  276. icon: 'none',
  277. title: "支付失败"
  278. })
  279. }
  280. });
  281. }
  282. })
  283. }
  284. })
  285. },
  286. }
  287. }
  288. </script>
  289. <style scoped lang="scss">
  290. .content {
  291. max-height: 80vh;
  292. overflow: hidden;
  293. overflow-y: auto;
  294. .address {
  295. display: flex;
  296. padding: 20rpx;
  297. background-color: #fff;
  298. image {
  299. width: 30rpx;
  300. height: 30rpx;
  301. margin: 20rpx;
  302. }
  303. view {
  304. margin: 20rpx;
  305. overflow: hidden; //超出的文本隐藏
  306. text-overflow: ellipsis; //溢出用省略号显示
  307. white-space: nowrap; //溢出不换行
  308. }
  309. .icon {
  310. margin-left: auto;
  311. }
  312. }
  313. .submit-info {
  314. background-color: #fff;
  315. padding: 30rpx;
  316. margin-top: 20rpx;
  317. .title {
  318. font-size: 30rpx;
  319. padding: 10rpx;
  320. font-weight: 600;
  321. }
  322. .box {
  323. display: flex;
  324. margin-top: 10rpx;
  325. .image {
  326. width: 200rpx;
  327. height: 200rpx;
  328. border-radius: 20rpx;
  329. margin-right: 20rpx;
  330. }
  331. .info {
  332. flex: 1;
  333. .unit {
  334. font-size: 24rpx;
  335. padding: 10rpx 20rpx;
  336. color: #717171;
  337. display: flex;
  338. align-items: center;
  339. }
  340. .price {
  341. color: $uni-color;
  342. font-size: 28rpx;
  343. padding: 10rpx 20rpx;
  344. text {
  345. font-size: 36rpx;
  346. font-weight: 900;
  347. }
  348. }
  349. }
  350. }
  351. }
  352. .submit-unit {
  353. padding: 30rpx;
  354. background-color: #fff;
  355. .title {
  356. font-size: 28rpx;
  357. font-weight: 600;
  358. }
  359. .list {
  360. display: flex;
  361. flex-wrap: wrap;
  362. font-size: 22rpx;
  363. .act {
  364. color: $uni-color;
  365. border: 1px solid $uni-color;
  366. background-color: #F9E7DE;
  367. }
  368. view {
  369. border-radius: 15rpx;
  370. width: 320rpx;
  371. background-color: #F3F3F3;
  372. border: 1px solid #F3F3F3;
  373. margin: 10rpx;
  374. display: flex;
  375. justify-content: center;
  376. padding: 15rpx 0;
  377. }
  378. }
  379. }
  380. .expense-detail {
  381. padding: 30rpx;
  382. background-color: #fff;
  383. font-size: 28rpx;
  384. .title {
  385. font-weight: 600;
  386. }
  387. .detail {
  388. background-color: #F6F6F6;
  389. color: #717171;
  390. margin: 10rpx 0;
  391. padding: 10rpx 20rpx;
  392. line-height: 50rpx;
  393. }
  394. .coupon{
  395. text-align: center;
  396. color: #5c5;
  397. }
  398. }
  399. .submit-btn {
  400. width: 600rpx;
  401. height: 80rpx;
  402. color: #fff;
  403. border-radius: 40rpx;
  404. font-size: 28rpx;
  405. margin: 20rpx auto;
  406. display: flex;
  407. justify-content: center;
  408. align-items: center;
  409. border: 1rpx solid $uni-color;
  410. overflow: hidden;
  411. .l {
  412. flex: 1;
  413. display: flex;
  414. justify-content: center;
  415. align-items: center;
  416. color: $uni-color;
  417. }
  418. .r {
  419. background: $uni-color;
  420. flex: 1;
  421. height: 100%;
  422. display: flex;
  423. justify-content: center;
  424. align-items: center;
  425. }
  426. }
  427. }
  428. </style>