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

376 lines
7.1 KiB

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
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
9 months ago
8 months ago
9 months ago
8 months ago
8 months ago
9 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
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
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
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
8 months ago
8 months ago
8 months ago
8 months ago
8 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/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 '../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. id: this.detail.id, //商品id
  154. skuId: this.unit.id, //规格id
  155. addressId: this.address.id, //地址id
  156. sku: this.unit.title, //规格
  157. num: this.num,
  158. }
  159. if (this.$utils.verificationAll(data, {
  160. skuId: '请选择规格',
  161. addressId: '请选择地址',
  162. })) {
  163. return
  164. }
  165. this.$api('orderCreate', {req:JSON.stringify(data)}, res => {
  166. if (res.code == 200) {
  167. let form = {
  168. id: res.result.id
  169. }
  170. this.$api('orderPay', form, res => {
  171. if (res.code == 200) {
  172. uni.requestPayment({
  173. provider: 'wxpay', // 服务提提供商
  174. timeStamp: res.result.timeStamp, // 时间戳
  175. nonceStr: res.result.nonceStr, // 随机字符串
  176. package: res.result.packageValue,
  177. signType: res.result.signType, // 签名算法
  178. paySign: res.result.paySign, // 签名
  179. success: function(res) {
  180. // console.log('支付成功', res);
  181. uni.redirectTo({
  182. url: '/pages/index/order'
  183. })
  184. },
  185. fail: function(err) {
  186. console.log('支付失败', err);
  187. // self.$refs.confirmationPopup.close()
  188. uni.showToast({
  189. icon: 'none',
  190. title: "支付失败"
  191. })
  192. }
  193. });
  194. }
  195. })
  196. }
  197. })
  198. },
  199. }
  200. }
  201. </script>
  202. <style scoped lang="scss">
  203. .content {
  204. max-height: 80vh;
  205. overflow: hidden;
  206. overflow-y: auto;
  207. .address {
  208. display: flex;
  209. padding: 20rpx;
  210. background-color: #fff;
  211. image {
  212. width: 30rpx;
  213. height: 30rpx;
  214. margin: 20rpx;
  215. }
  216. view {
  217. margin: 20rpx;
  218. overflow: hidden; //超出的文本隐藏
  219. text-overflow: ellipsis; //溢出用省略号显示
  220. white-space: nowrap; //溢出不换行
  221. }
  222. .icon {
  223. margin-left: auto;
  224. }
  225. }
  226. .submit-info {
  227. background-color: #fff;
  228. padding: 30rpx;
  229. margin-top: 20rpx;
  230. .title {
  231. font-size: 30rpx;
  232. padding: 10rpx;
  233. font-weight: 600;
  234. }
  235. .box {
  236. display: flex;
  237. margin-top: 10rpx;
  238. .image {
  239. width: 200rpx;
  240. height: 200rpx;
  241. border-radius: 20rpx;
  242. margin-right: 20rpx;
  243. }
  244. .info {
  245. flex: 1;
  246. .unit {
  247. font-size: 24rpx;
  248. padding: 10rpx 20rpx;
  249. color: #717171;
  250. display: flex;
  251. align-items: center;
  252. }
  253. .price {
  254. color: $uni-color;
  255. font-size: 28rpx;
  256. padding: 10rpx 20rpx;
  257. text {
  258. font-size: 36rpx;
  259. font-weight: 900;
  260. }
  261. }
  262. }
  263. }
  264. }
  265. .submit-unit {
  266. padding: 30rpx;
  267. background-color: #fff;
  268. .title {
  269. font-size: 28rpx;
  270. font-weight: 600;
  271. }
  272. .list {
  273. display: flex;
  274. flex-wrap: wrap;
  275. font-size: 22rpx;
  276. .act {
  277. color: $uni-color;
  278. border: 1px solid $uni-color;
  279. background-color: #F9E7DE;
  280. }
  281. view {
  282. border-radius: 15rpx;
  283. width: 320rpx;
  284. background-color: #F3F3F3;
  285. border: 1px solid #F3F3F3;
  286. margin: 10rpx;
  287. display: flex;
  288. justify-content: center;
  289. padding: 15rpx 0;
  290. }
  291. }
  292. }
  293. .expense-detail {
  294. padding: 30rpx;
  295. background-color: #fff;
  296. font-size: 28rpx;
  297. .title {
  298. font-weight: 600;
  299. }
  300. .detail {
  301. background-color: #F6F6F6;
  302. color: #717171;
  303. margin: 10rpx 0;
  304. padding: 10rpx 20rpx;
  305. }
  306. }
  307. .submit-btn {
  308. width: 600rpx;
  309. height: 80rpx;
  310. color: #fff;
  311. border-radius: 40rpx;
  312. font-size: 28rpx;
  313. margin: 20rpx auto;
  314. display: flex;
  315. justify-content: center;
  316. align-items: center;
  317. border: 1rpx solid $uni-color;
  318. overflow: hidden;
  319. .l {
  320. flex: 1;
  321. display: flex;
  322. justify-content: center;
  323. align-items: center;
  324. color: $uni-color;
  325. }
  326. .r {
  327. background: $uni-color;
  328. flex: 1;
  329. height: 100%;
  330. display: flex;
  331. justify-content: center;
  332. align-items: center;
  333. }
  334. }
  335. }
  336. </style>