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

605 lines
13 KiB

7 months ago
6 months ago
7 months ago
6 months ago
7 months ago
6 months ago
6 months ago
7 months ago
6 months ago
7 months ago
6 months ago
5 months ago
6 months ago
7 months ago
5 months ago
7 months ago
6 months ago
5 months ago
7 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
4 months ago
5 months ago
6 months ago
6 months ago
5 months ago
6 months ago
6 months ago
4 months ago
5 months ago
5 months ago
4 months ago
6 months ago
6 months ago
6 months ago
4 months ago
6 months ago
6 months ago
6 months ago
4 months ago
6 months ago
4 months ago
6 months ago
6 months ago
4 months ago
6 months ago
4 months ago
6 months ago
5 months ago
4 months ago
5 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
5 months ago
6 months ago
6 months ago
6 months ago
7 months ago
6 months ago
5 months ago
6 months ago
7 months ago
6 months ago
7 months ago
7 months ago
6 months ago
7 months ago
6 months ago
6 months ago
7 months ago
6 months ago
7 months ago
6 months ago
6 months ago
4 months ago
5 months ago
7 months ago
6 months ago
7 months ago
6 months ago
6 months ago
4 months ago
7 months ago
6 months ago
6 months ago
6 months ago
7 months ago
6 months ago
6 months ago
5 months ago
6 months ago
4 months ago
5 months ago
7 months ago
7 months ago
6 months ago
7 months ago
6 months ago
6 months ago
5 months ago
7 months ago
6 months ago
7 months ago
6 months ago
6 months ago
4 months ago
7 months ago
6 months ago
7 months ago
6 months ago
7 months ago
7 months ago
6 months ago
6 months ago
6 months ago
6 months ago
7 months ago
6 months ago
7 months ago
6 months ago
7 months ago
6 months ago
7 months ago
6 months ago
7 months ago
7 months ago
6 months ago
7 months ago
6 months ago
7 months ago
6 months ago
7 months ago
6 months ago
6 months ago
7 months ago
6 months ago
7 months ago
6 months ago
5 months ago
6 months ago
5 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
4 months ago
6 months ago
4 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
7 months ago
7 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
7 months ago
6 months ago
7 months ago
6 months ago
5 months ago
6 months ago
7 months ago
6 months ago
7 months ago
5 months ago
6 months ago
7 months ago
6 months ago
7 months ago
6 months ago
7 months ago
6 months ago
6 months ago
5 months ago
6 months ago
6 months ago
7 months ago
6 months ago
6 months ago
6 months ago
6 months ago
7 months ago
7 months ago
6 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-unit"
  21. style="margin-top: 20rpx;">
  22. <view class="title">
  23. 您有{{ detail.categoryName }}
  24. </view>
  25. <view class="list">
  26. <view :class="{act : typeIndex == index}" v-for="(item, index) in type"
  27. @click="typeIndex = index" :key="index">
  28. {{ item }}{{ detail.categoryName }}
  29. </view>
  30. </view>
  31. </view> -->
  32. <!-- 我要购买租赁 -->
  33. <!-- <view class="submit-unit"
  34. style="margin-top: 20rpx;">
  35. <view class="list">
  36. <view :class="{act : buyIndex == index}"
  37. v-for="(item, index) in buyType"
  38. @click="buyIndex = index"
  39. :key="index">
  40. {{ item }}
  41. </view>
  42. </view>
  43. </view> -->
  44. <view class="payInfoMessage"
  45. v-if="buyIndex == 0">
  46. <view style="font-weight: 900;">
  47. 下单说明
  48. </view>
  49. <view class="">
  50. 租金物品确认收货后每张桌布每天租金{{ configList.depositPrice }}
  51. </view>
  52. <view class="">
  53. 押金按桌布最低成本价收取订单结束后全额退还
  54. </view>
  55. </view>
  56. <!-- 商品信息和数量 -->
  57. <view v-if="typeIndex == 0">
  58. <view class="submit-info">
  59. <view class="title">
  60. {{ detail.categoryName }}租赁
  61. </view>
  62. <view class="box">
  63. <image class="image" :src="unit.pic" mode=""></image>
  64. <view class="info">
  65. <view class="price">
  66. 租金<text>{{ detail.depositPrice }}</text>/
  67. </view>
  68. <view class="price"
  69. style="font-size: 22rpx;">
  70. 押金<text
  71. style="font-size: 22rpx;">{{ unit.price }}</text>
  72. </view>
  73. <view class="unit">
  74. 请选择规格
  75. </view>
  76. <view class="">
  77. <uv-number-box
  78. @change="valChange"
  79. v-model="num"></uv-number-box>
  80. </view>
  81. </view>
  82. </view>
  83. </view>
  84. <!-- 规格 -->
  85. <!-- <view class="submit-unit">
  86. <view class="title">
  87. 规格选择
  88. </view>
  89. <view class="list">
  90. <view :class="{act : unitIndex == index}"
  91. v-for="(item, index) in detail.hotelGoodsSkuList"
  92. @click="selectUnit(item, index)" :key="index">
  93. {{ item.title }}
  94. <text v-if="item.colour">,{{ item.colour }}</text>
  95. </view>
  96. </view>
  97. </view> -->
  98. <selectProductUnit
  99. :list="detail.hotelGoodsSkuList"
  100. @selectUnit="selectUnit"
  101. />
  102. <!-- 优惠劵 -->
  103. <!-- <view style="padding: 0 20rpx;">
  104. <uv-cell
  105. icon="coupon"
  106. title="优惠劵"
  107. iconStyle="font-size: 34rpx;"
  108. rightIconStyle="font-size: 34rpx;"
  109. :value="couponText"
  110. @click="$refs.couponPopup.open('bottom')"
  111. isLink>
  112. </uv-cell>
  113. </view> -->
  114. <!-- 费用明细 -->
  115. <view class="expense-detail">
  116. <view class="title">
  117. 费用明细
  118. </view>
  119. <view class="detail" v-if="unit.price">
  120. <view>
  121. 应付款{{ price }}
  122. </view>
  123. <view>
  124. <view class="">
  125. 押金{{ unit.price }}
  126. </view>
  127. <view class="">
  128. x{{ num }}
  129. </view>
  130. </view>
  131. <view v-if="coupon.couponCondition <= price
  132. && coupon.couponFlag">
  133. 优惠-{{ coupon.couponPrice }}
  134. </view>
  135. <view v-if="coupon.couponCondition <= price
  136. && coupon.couponFlag">
  137. 实付款{{ (price - coupon.couponPrice).toFixed(2) }}
  138. </view>
  139. </view>
  140. <uv-cell
  141. icon="coupon"
  142. title="押金优惠"
  143. v-if="coupon.couponFlag"
  144. iconStyle="font-size: 34rpx;"
  145. rightIconStyle="font-size: 34rpx;">
  146. <template #value>
  147. <view class="coupon">
  148. {{ coupon.couponCondition }}立减{{ coupon.couponPrice }}
  149. </view>
  150. </template>
  151. </uv-cell>
  152. </view>
  153. </view>
  154. <addLeaseForm :categoryId="detail.categoryId" ref="addLeaseForm" v-if="typeIndex == 1"/>
  155. <!-- 提交按钮 -->
  156. <view class="submit">
  157. <view class="submit-btn">
  158. <view class="l" @click="addCart" v-if="typeIndex == 0">
  159. 加入租赁车
  160. </view>
  161. <view class="r" @click="orderPay">
  162. {{ submiitTitle }}
  163. </view>
  164. </view>
  165. </view>
  166. </view>
  167. <uv-popup ref="couponPopup" :round="30">
  168. <couponList
  169. ref="couponList"
  170. height="60vh"
  171. :depositPrice="price"
  172. @select="selectCoupon" />
  173. </uv-popup>
  174. <uv-popup ref="addressPopup" :round="30">
  175. <addressList ref="addressList" height="60vh" @select="selectAddress" />
  176. </uv-popup>
  177. </uv-popup>
  178. </template>
  179. <script>
  180. import addressList from '@/components/address/addressList.vue'
  181. import couponList from '@/components/user/couponList.vue'
  182. import addLeaseForm from './addLeaseForm.vue'
  183. import selectProductUnit from '@/components/user/selectProductUnit.vue'
  184. import { mapState } from 'vuex'
  185. export default {
  186. components: {
  187. addressList,
  188. couponList,
  189. addLeaseForm,
  190. selectProductUnit,
  191. },
  192. props: {
  193. submiitTitle: {
  194. default: '立即下单',
  195. type: String,
  196. },
  197. detail: {
  198. default: {}
  199. },
  200. },
  201. computed : {
  202. ...mapState(['configList']),
  203. price(){
  204. return (this.unit.price * this.num).toFixed(2)
  205. // return (this.detail.depositPrice * this.num).toFixed(2)
  206. },
  207. },
  208. data() {
  209. return {
  210. unitIndex: 0,
  211. address: {
  212. name: '请选择联系人',
  213. addressDetail: '',
  214. },
  215. num: 1,
  216. unit: {},
  217. addressTotal: 0,
  218. coupon : {
  219. price : 0,
  220. },
  221. couponText : '请选择',
  222. typeIndex : 0,//是否有桌布
  223. type : ['没有', '我有'],//是否有桌布
  224. buyIndex : 0,//是否有桌布
  225. buyType : ['我要租赁', '我要购买'],//是否购买
  226. }
  227. },
  228. methods: {
  229. // 打开
  230. open() {
  231. this.$refs.popup.open('bottom')
  232. // this.$refs.couponList.getData()
  233. this.confCoupon()
  234. if (!this.unit.id) {
  235. // this.selectUnit(this.detail.hotelGoodsSkuList[0], 0)
  236. }
  237. // 获取地址列表
  238. this.$refs.addressList.getAddressList().then(res => {
  239. this.addressTotal = res.total
  240. if (this.addressTotal != 0) {
  241. this.address = res.records[0]
  242. }
  243. })
  244. },
  245. confCoupon(){
  246. this.$api('confCoupon', res => {
  247. if(res.code == 200){
  248. this.coupon = res.result
  249. }
  250. })
  251. },
  252. valChange(){
  253. // this.coupon = {
  254. // price : 0,
  255. // }
  256. // this.couponText = '请选择'
  257. },
  258. // 选择优惠劵
  259. selectCoupon(e){
  260. this.couponText = e.couponName
  261. this.coupon = e
  262. this.$refs.couponPopup.close()
  263. },
  264. // 关闭
  265. close() {
  266. this.$refs.popup.close()
  267. },
  268. // 打开选择地址
  269. openAddress() {
  270. if (this.addressTotal == 0) {
  271. this.$refs.popup.close()
  272. return uni.navigateTo({
  273. url: '/pages_order/mine/address?type=back'
  274. })
  275. }
  276. this.$refs.addressPopup.open('bottom')
  277. },
  278. // 选择地址
  279. selectAddress(e) {
  280. this.address = e
  281. this.$refs.addressPopup.close()
  282. },
  283. // 选择规格
  284. selectUnit(item, index) {
  285. this.unit = item
  286. this.unitIndex = index
  287. },
  288. addCart() {
  289. this.$api('cartAdd', {
  290. id: this.detail.id,
  291. skuId: this.unit.id,
  292. num : this.num,
  293. }, res => {
  294. if (res.code == 200) {
  295. uni.showToast({
  296. title: '添加成功',
  297. });
  298. this.$refs.popup.close()
  299. }
  300. })
  301. },
  302. // 添加我的物品
  303. submitAddLease() {
  304. if(!this.address.id){
  305. return uni.showToast({
  306. title: '请选择地址'
  307. })
  308. }
  309. this.$refs.addLeaseForm.submit(form => {
  310. form.addressId = this.address.id, //地址id
  311. this.$api('tablecloth', form, res => {
  312. if (res.code == 200) {
  313. uni.redirectTo({
  314. url: '/pages_order/order/createWash?id=1'
  315. })
  316. }
  317. })
  318. })
  319. },
  320. orderPay() {
  321. // 添加我的物品
  322. if(this.typeIndex == 1){
  323. return this.submitAddLease()
  324. }
  325. // 租赁物品
  326. let data = [
  327. {
  328. id: this.detail.id, //商品id
  329. skuId: this.unit.id, //规格id
  330. addressId: this.address.id, //地址id
  331. sku: this.unit.unitKeyName, //规格
  332. num: this.num,
  333. }
  334. ]
  335. if(this.unit.colour){
  336. data[0].sku = data[0].sku + ',' + this.unit.colour
  337. }
  338. if (this.$utils.verificationAll(data[0], {
  339. skuId: '请选择规格',
  340. addressId: '请选择地址',
  341. })) {
  342. return
  343. }
  344. this.$api('orderCreate', {req:JSON.stringify(data)}, res => {
  345. if (res.code == 200) {
  346. let form = {
  347. id: res.result.id,
  348. }
  349. if(this.coupon.id){
  350. form.couponId = this.coupon.id
  351. }
  352. this.$api('orderPay', form, res => {
  353. if (res.code == 200) {
  354. uni.requestPayment({
  355. provider: 'wxpay', // 服务提提供商
  356. timeStamp: res.result.timeStamp, // 时间戳
  357. nonceStr: res.result.nonceStr, // 随机字符串
  358. package: res.result.packageValue,
  359. signType: res.result.signType, // 签名算法
  360. paySign: res.result.paySign, // 签名
  361. success: function(res) {
  362. // console.log('支付成功', res);
  363. uni.redirectTo({
  364. url: '/pages/index/order'
  365. })
  366. },
  367. fail: function(err) {
  368. console.log('支付失败', err);
  369. uni.redirectTo({
  370. url:'/pages/index/order'
  371. })
  372. // self.$refs.confirmationPopup.close()
  373. uni.showToast({
  374. icon: 'none',
  375. title: "支付失败"
  376. })
  377. }
  378. });
  379. }
  380. })
  381. }
  382. })
  383. },
  384. }
  385. }
  386. </script>
  387. <style scoped lang="scss">
  388. .content {
  389. max-height: 70vh;
  390. overflow: hidden;
  391. overflow-y: auto;
  392. padding-bottom: 120rpx;
  393. .address {
  394. display: flex;
  395. padding: 20rpx;
  396. background-color: #fff;
  397. image {
  398. width: 30rpx;
  399. height: 30rpx;
  400. margin: 20rpx;
  401. }
  402. view {
  403. margin: 20rpx;
  404. overflow: hidden; //超出的文本隐藏
  405. text-overflow: ellipsis; //溢出用省略号显示
  406. white-space: nowrap; //溢出不换行
  407. }
  408. .icon {
  409. margin-left: auto;
  410. }
  411. }
  412. .payInfoMessage{
  413. line-height: 50rpx;
  414. background-color: #fff;
  415. padding: 20rpx;
  416. margin: 10rpx 0;
  417. font-size: 26rpx;
  418. }
  419. .submit-info {
  420. background-color: #fff;
  421. padding: 30rpx;
  422. margin-top: 20rpx;
  423. .title {
  424. font-size: 30rpx;
  425. padding: 10rpx;
  426. font-weight: 600;
  427. }
  428. .box {
  429. display: flex;
  430. margin-top: 10rpx;
  431. .image {
  432. width: 200rpx;
  433. height: 200rpx;
  434. border-radius: 20rpx;
  435. margin-right: 20rpx;
  436. }
  437. .info {
  438. flex: 1;
  439. .unit {
  440. font-size: 24rpx;
  441. padding: 10rpx 20rpx;
  442. color: #717171;
  443. display: flex;
  444. align-items: center;
  445. }
  446. .price {
  447. color: $uni-color;
  448. font-size: 28rpx;
  449. padding: 10rpx 20rpx;
  450. text {
  451. font-size: 36rpx;
  452. font-weight: 900;
  453. }
  454. }
  455. }
  456. }
  457. }
  458. .submit-unit {
  459. padding: 30rpx;
  460. background-color: #fff;
  461. .title {
  462. font-size: 28rpx;
  463. font-weight: 600;
  464. }
  465. .list {
  466. display: flex;
  467. flex-wrap: wrap;
  468. font-size: 22rpx;
  469. .act {
  470. color: $uni-color;
  471. border: 1px solid $uni-color;
  472. background-color: #F9E7DE;
  473. }
  474. view {
  475. border-radius: 15rpx;
  476. width: 320rpx;
  477. background-color: #F3F3F3;
  478. border: 1px solid #F3F3F3;
  479. margin: 10rpx;
  480. display: flex;
  481. justify-content: center;
  482. padding: 15rpx 0;
  483. }
  484. }
  485. }
  486. .expense-detail {
  487. padding: 30rpx;
  488. background-color: #fff;
  489. font-size: 28rpx;
  490. .title {
  491. font-weight: 600;
  492. }
  493. .detail {
  494. background-color: #F6F6F6;
  495. color: #717171;
  496. margin: 10rpx 0;
  497. padding: 10rpx 20rpx;
  498. line-height: 50rpx;
  499. view{
  500. display: flex;
  501. justify-content: space-between;
  502. }
  503. }
  504. .coupon{
  505. text-align: center;
  506. color: #5c5;
  507. }
  508. }
  509. .submit{
  510. background-color: #fff;
  511. position: fixed;
  512. left: 0;
  513. bottom: 0;
  514. padding-bottom: env(safe-area-inset-bottom);
  515. width: 100%;
  516. .submit-btn {
  517. width: 600rpx;
  518. height: 80rpx;
  519. color: #fff;
  520. border-radius: 40rpx;
  521. font-size: 28rpx;
  522. margin: 20rpx auto;
  523. display: flex;
  524. justify-content: center;
  525. align-items: center;
  526. border: 1rpx solid $uni-color;
  527. overflow: hidden;
  528. .l {
  529. flex: 1;
  530. display: flex;
  531. justify-content: center;
  532. align-items: center;
  533. color: $uni-color;
  534. }
  535. .r {
  536. background: $uni-color;
  537. flex: 1;
  538. height: 100%;
  539. display: flex;
  540. justify-content: center;
  541. align-items: center;
  542. }
  543. }
  544. }
  545. }
  546. </style>