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

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