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

446 lines
8.7 KiB

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