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

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