瑶都万能墙
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.

367 lines
7.0 KiB

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