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

335 lines
6.7 KiB

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
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
  1. <template>
  2. <uv-popup ref="popup"
  3. :round="30"
  4. @change="$refs.couponPopup.close()"
  5. bgColor="#f7f7f7">
  6. <view class="content">
  7. <!-- 地址 -->
  8. <view class="address" @click="openAddress">
  9. <image src="/static/image/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 size="30rpx" name="arrow-right"></uv-icon>
  18. </view>
  19. </view>
  20. <!-- 优惠劵 -->
  21. <!-- <view style="padding: 0 20rpx;
  22. background-color: #fff;">
  23. <uv-cell
  24. icon="coupon"
  25. title="优惠劵"
  26. iconStyle="font-size: 34rpx;"
  27. rightIconStyle="font-size: 34rpx;"
  28. :value="couponText"
  29. @click="$refs.couponPopup.open('bottom')"
  30. isLink>
  31. </uv-cell>
  32. </view> -->
  33. <!-- 费用明细 -->
  34. <view class="expense-detail">
  35. <view class="title">
  36. 费用明细
  37. </view>
  38. <view class="detail" v-if="price">
  39. <view>
  40. 应付款{{ price }}
  41. </view>
  42. <view v-if="depositPrice">
  43. 押金{{ depositPrice }}
  44. </view>
  45. <view v-if="washPrice">
  46. 水洗费{{ washPrice }}
  47. </view>
  48. <view v-if="rentPrice">
  49. 租金{{ rentPrice }}
  50. </view>
  51. <view v-if="getPrice().coupon">
  52. 优惠-{{ getPrice().coupon }}
  53. </view>
  54. <view v-if="getPrice().price">
  55. 实付款{{ getPrice().price }}
  56. </view>
  57. </view>
  58. <uv-cell
  59. icon="coupon"
  60. title="押金优惠"
  61. v-if="coupon.couponFlag"
  62. iconStyle="font-size: 34rpx;"
  63. rightIconStyle="font-size: 34rpx;">
  64. <template #value>
  65. <view class="coupon">
  66. {{ coupon.couponCondition }}立减{{ coupon.couponPrice }}
  67. </view>
  68. </template>
  69. </uv-cell>
  70. <uv-cell
  71. icon="coupon"
  72. title="租金优惠"
  73. v-if="coupon.leaseCouponFlag"
  74. iconStyle="font-size: 34rpx;"
  75. rightIconStyle="font-size: 34rpx;">
  76. <template #value>
  77. <view class="coupon">
  78. {{ coupon.leaseCouponCondition }}立减{{ coupon.leaseCouponPrice }}
  79. </view>
  80. </template>
  81. </uv-cell>
  82. </view>
  83. <!-- 提交按钮 -->
  84. <view class="submit-btn">
  85. <view class="r" @click="orderPay">
  86. {{ submiitTitle }}
  87. </view>
  88. </view>
  89. </view>
  90. <uv-popup ref="couponPopup"
  91. :round="30">
  92. <couponList
  93. ref="couponList"
  94. height="60vh"
  95. :depositPrice="depositPrice"
  96. :washPrice="washPrice"
  97. :rentPrice="rentPrice"
  98. :useType="0"
  99. @select="selectCoupon" />
  100. </uv-popup>
  101. <uv-popup ref="addressPopup" :round="30">
  102. <addressList ref="addressList" height="60vh" @select="selectAddress" />
  103. </uv-popup>
  104. </uv-popup>
  105. </template>
  106. <script>
  107. import addressList from '@/components/address/addressList.vue'
  108. import couponList from './couponList.vue'
  109. export default {
  110. components: {
  111. addressList,
  112. couponList,
  113. },
  114. props: {
  115. submiitTitle: {
  116. default: '立即下单',
  117. type: String,
  118. },
  119. price : {//总金额
  120. default : 0
  121. },
  122. depositPrice: {//押金
  123. default: 0
  124. },
  125. washPrice: {//水洗费
  126. default: 0
  127. },
  128. rentPrice: {//租金
  129. default: 0
  130. },
  131. },
  132. data() {
  133. return {
  134. address: {
  135. name: '请选择联系人',
  136. addressDetail: '',
  137. },
  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. // this.$refs.couponPopup.close()
  151. this.confCoupon()
  152. // 获取地址列表
  153. this.$refs.addressList.getAddressList().then(res => {
  154. this.addressTotal = res.total
  155. if (this.addressTotal != 0) {
  156. this.address = res.records[0]
  157. }
  158. })
  159. },
  160. // 计算优惠金额
  161. getPrice(){
  162. // 减免押金
  163. if(this.coupon.couponFlag &&
  164. this.coupon.couponCondition <= this.depositPrice){
  165. return {
  166. coupon : this.coupon.couponPrice,
  167. price : (this.price - this.coupon.couponPrice).toFixed(2),
  168. }
  169. }
  170. // 减免租金
  171. if(this.coupon.leaseCouponFlag &&
  172. this.coupon.leaseCouponCondition <= this.rentPrice){
  173. return {
  174. coupon : this.coupon.leaseCouponPrice,
  175. price : (this.price - this.coupon.leaseCouponPrice).toFixed(2),
  176. }
  177. }
  178. return {}
  179. },
  180. // 选择优惠劵
  181. selectCoupon(e){
  182. this.couponText = e.couponName
  183. this.coupon = e
  184. this.$refs.couponPopup.close()
  185. },
  186. // 关闭
  187. close() {
  188. this.$refs.popup.close()
  189. },
  190. // 打开选择地址
  191. openAddress() {
  192. if (this.addressTotal == 0) {
  193. this.$refs.popup.close()
  194. return uni.navigateTo({
  195. url: '/pages_order/mine/address?type=back'
  196. })
  197. }
  198. this.$refs.addressPopup.open('bottom')
  199. },
  200. // 选择地址
  201. selectAddress(e) {
  202. this.address = e
  203. this.$refs.addressPopup.close()
  204. },
  205. // 选择规格
  206. selectUnit(item, index) {
  207. this.unit = item
  208. this.unitIndex = index
  209. },
  210. addCart() {
  211. this.$api('cartAdd', {
  212. id: this.detail.id,
  213. skuId: this.unit.id,
  214. }, res => {
  215. if (res.code == 200) {
  216. uni.showToast({
  217. title: '添加成功',
  218. });
  219. this.$refs.popup.close()
  220. }
  221. })
  222. },
  223. orderPay() {
  224. this.$emit('submit', {
  225. addressId : this.address.id,
  226. couponId : this.coupon.id
  227. })
  228. },
  229. confCoupon(){
  230. this.$api('confCoupon', res => {
  231. if(res.code == 200){
  232. this.coupon = res.result
  233. }
  234. })
  235. },
  236. }
  237. }
  238. </script>
  239. <style scoped lang="scss">
  240. .content {
  241. max-height: 80vh;
  242. overflow: hidden;
  243. overflow-y: auto;
  244. padding-top: 30rpx;
  245. .address {
  246. display: flex;
  247. padding: 20rpx;
  248. background-color: #fff;
  249. margin-bottom: 20rpx;
  250. image {
  251. width: 30rpx;
  252. height: 30rpx;
  253. margin: 20rpx;
  254. }
  255. view {
  256. margin: 20rpx;
  257. overflow: hidden; //超出的文本隐藏
  258. text-overflow: ellipsis; //溢出用省略号显示
  259. white-space: nowrap; //溢出不换行
  260. }
  261. .icon {
  262. margin-left: auto;
  263. }
  264. }
  265. .expense-detail {
  266. padding: 30rpx;
  267. background-color: #fff;
  268. font-size: 28rpx;
  269. .title {
  270. font-weight: 600;
  271. }
  272. .detail {
  273. background-color: #F6F6F6;
  274. color: #717171;
  275. margin: 10rpx 0;
  276. padding: 10rpx 20rpx;
  277. line-height: 50rpx;
  278. }
  279. .coupon{
  280. text-align: center;
  281. color: #5c5;
  282. }
  283. }
  284. .submit-btn {
  285. width: 600rpx;
  286. height: 80rpx;
  287. color: #fff;
  288. border-radius: 40rpx;
  289. font-size: 28rpx;
  290. margin: 20rpx auto;
  291. display: flex;
  292. justify-content: center;
  293. align-items: center;
  294. border: 1rpx solid $uni-color;
  295. overflow: hidden;
  296. .l {
  297. flex: 1;
  298. display: flex;
  299. justify-content: center;
  300. align-items: center;
  301. color: $uni-color;
  302. }
  303. .r {
  304. background: $uni-color;
  305. flex: 1;
  306. height: 100%;
  307. display: flex;
  308. justify-content: center;
  309. align-items: center;
  310. }
  311. }
  312. }
  313. </style>