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

528 lines
11 KiB

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