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

454 lines
9.5 KiB

5 months ago
  1. <template>
  2. <view class="page">
  3. <navbar title="我要水洗" leftClick @leftClick="$utils.navigateBack" />
  4. <view class="tabs">
  5. <uv-tabs :list="tabs" :activeStyle="{color : '#FD5100', fontWeight : 600}" lineColor="#FD5100" lineHeight="8rpx"
  6. lineWidth="50rpx" :scrollable="false" @click="clickTabs"></uv-tabs>
  7. </view>
  8. <!-- 选择租赁物品 -->
  9. <view class="box d">
  10. <uv-checkbox-group shape="circle" v-model="checkboxValue"
  11. >
  12. <view v-for="(item, index) in list" :key="index" class="item">
  13. <view class="checkbox">
  14. <!-- <uv-checkbox
  15. :name="item.id"
  16. :disabled="item.status != 0
  17. || !item.startTime && item.leaseFlag
  18. || item.isWash"
  19. activeColor="#FA5A0A"
  20. size="40rpx"
  21. icon-size="35rpx"></uv-checkbox> -->
  22. <uv-checkbox
  23. :name="item.id"
  24. :disabled="!!item.statusInfo"
  25. activeColor="#FA5A0A"
  26. size="40rpx"
  27. icon-size="35rpx"></uv-checkbox>
  28. </view>
  29. <image class="image" :src="item.goodsPic || 'https://img95.699pic.com/photo/50058/1378.jpg_wh860.jpg'"
  30. mode=""></image>
  31. <view class="info">
  32. <view class="title">
  33. <view>{{ item.goodsName }}</view>
  34. <view>
  35. <!-- <uv-number-box v-model="item.num" @change="e => valChange(item, e)"></uv-number-box> -->
  36. 数量{{ item.num }}
  37. </view>
  38. </view>
  39. <view class="unit">
  40. 规格{{ item.sku }}
  41. <!-- <uv-icon name="arrow-down"></uv-icon> -->
  42. </view>
  43. <!-- <view class="wan"
  44. v-if="!item.startTime
  45. && item.leaseFlag
  46. && item.status == 0">
  47. 确认收货后方可水洗
  48. </view>
  49. <view class="wan" v-else-if="item.status != 0">
  50. {{ statusText[item.status] }}
  51. </view>
  52. <view class="wan" v-else-if="item.isWash">
  53. 水洗中
  54. </view> -->
  55. <view class="wan" v-if="item.statusInfo">
  56. {{ item.statusInfo }}
  57. </view>
  58. <view class="price" v-else>
  59. <view class="" v-if="item.zujin">
  60. 租金
  61. <text>{{ item.zujin }}</text>
  62. </view>
  63. <view class="" v-if="item.washPrice">
  64. 水洗费
  65. <text>{{ item.washPrice }}</text>
  66. </view>
  67. </view>
  68. </view>
  69. </view>
  70. </uv-checkbox-group>
  71. </view>
  72. <!-- <view class="btn" @click="submit">
  73. <button class="a">水洗下单<text v-if="price">{{price}}</text></button>
  74. </view> -->
  75. <view class="action">
  76. <view class="icon">
  77. <image src="/static/image/cart/1.png" mode=""></image>
  78. <view class="num">{{ checkboxValue.length }}</view>
  79. </view>
  80. <view class="price">
  81. <view class="count">
  82. 合计
  83. <view>
  84. <text>{{ price }}</text>
  85. </view>
  86. </view>
  87. <view class="text">
  88. <!-- {{ checkboxValue.length }}已享受更低优惠 -->
  89. 含租金{{zujin}}水洗费{{washPrice}}
  90. </view>
  91. </view>
  92. <view class="btn2" @click="goCleaning">结算</view>
  93. </view>
  94. <cartSubmitSelect
  95. @submit="ordersPay"
  96. :price="price"
  97. :washPrice="washPrice"
  98. :rentPrice="zujin"
  99. submiitTitle="立即水洗"
  100. ref="cartSubmitSelect"/>
  101. </view>
  102. </template>
  103. <script>
  104. import cartSubmitSelect from '@/components/user/cartSubmitSelect.vue'
  105. import mixinsList from '@/mixins/list.js'
  106. import mixinLease from '@/mixins/lease.js'
  107. export default {
  108. mixins : [mixinsList, mixinLease],
  109. components: {
  110. cartSubmitSelect,
  111. },
  112. data() {
  113. return {
  114. checkboxValue : [],
  115. statusText : ['正常', '换货中', '退货中'],
  116. tabs: [{
  117. name: '选择租赁物品'
  118. },
  119. {
  120. name: '选择我的物品'
  121. },
  122. ],
  123. type: 1,
  124. mixinsListApi : 'getLeasePage',
  125. }
  126. },
  127. computed : {
  128. price(){
  129. return this.washPrice + this.zujin
  130. },
  131. washPrice(){
  132. if(this.checkboxValue.length == 0){
  133. return 0
  134. }
  135. let price = 0
  136. this.list.forEach(n => {
  137. if(this.checkboxValue.includes(n.id)){
  138. price += n.washPrice || 0
  139. }
  140. })
  141. return price
  142. },
  143. zujin(){
  144. if(this.checkboxValue.length == 0){
  145. return 0
  146. }
  147. let price = 0
  148. this.list.forEach(n => {
  149. if(this.checkboxValue.includes(n.id)){
  150. price += n.zujin || 0
  151. }
  152. })
  153. return price
  154. },
  155. },
  156. onShow() {
  157. this.getData()
  158. },
  159. methods: {
  160. //点击tab栏
  161. clickTabs({
  162. index,
  163. name
  164. }) {
  165. this.type = index ? 0 : 1;
  166. this.queryParams.pageSize = 10
  167. this.checkboxValue = []
  168. // this.mixinsListApi = ['orderPage', 'orderPage'][index]
  169. this.getData()
  170. },
  171. // 发请求之前处理参数
  172. beforeGetData(){
  173. let data = {}
  174. data.leaseFlag = this.type
  175. return data
  176. },
  177. getDataThen(list){
  178. // list[0] && list[0].d = true
  179. list.forEach(n => {
  180. n.statusInfo = this.isLeaseStatus(n)
  181. })
  182. },
  183. // 去结算按钮
  184. goCleaning() {
  185. if (this.checkboxValue.length < 1) {
  186. uni.showToast({
  187. title: "请勾选商品",
  188. icon: 'none'
  189. })
  190. return
  191. }
  192. this.$refs.cartSubmitSelect.open('bottom')
  193. },
  194. //商品下单
  195. ordersPay({ addressId, couponId }) {
  196. var self = this
  197. // var deleteCartIds = this.checkboxValue.join(",") //待删除的购物车id
  198. let data = []
  199. let records = this.list
  200. for (var i = 0; i < records.length; i++) {
  201. if (this.checkboxValue.includes(records[i].id)) {
  202. data.push({
  203. leaseId: records[i].id, //租赁id
  204. addressId, //地址id
  205. type : 1,
  206. })
  207. }
  208. }
  209. this.$api('orderCreate', {
  210. req: JSON.stringify(data)
  211. }, res => {
  212. if (res.code == 200) {
  213. let form = {
  214. id: res.result.id
  215. }
  216. if(couponId){
  217. form.couponId = couponId
  218. }
  219. // 不管有没有支付,都要清除购物车数据
  220. // self.$api('cartDel', {
  221. // id: deleteCartIds
  222. // }, res => {
  223. // if (res.code == 200) {
  224. // self.getData()
  225. // }
  226. // })
  227. this.$api('orderPay', form, res => {
  228. if (res.code == 200) {
  229. uni.requestPayment({
  230. provider: 'wxpay', // 服务提提供商
  231. timeStamp: res.result.timeStamp, // 时间戳
  232. nonceStr: res.result.nonceStr, // 随机字符串
  233. package: res.result.packageValue,
  234. signType: res.result.signType, // 签名算法
  235. paySign: res.result.paySign, // 签名
  236. success: function(res) {
  237. console.log('支付成功', res);
  238. uni.redirectTo({
  239. url: '/pages/index/order'
  240. })
  241. },
  242. fail: function(err) {
  243. console.log('支付失败', err);
  244. // self.$refs.confirmationPopup.close()
  245. uni.redirectTo({
  246. url: '/pages/index/order'
  247. })
  248. uni.showToast({
  249. icon: 'none',
  250. title: "支付失败"
  251. })
  252. }
  253. });
  254. }
  255. })
  256. }
  257. })
  258. },
  259. }
  260. }
  261. </script>
  262. <style scoped lang="scss">
  263. .page {
  264. padding-bottom: 200rpx;
  265. .tabs{
  266. position: sticky;
  267. top: calc(var(--status-bar-height) + 120rpx);
  268. background-color: #fff;
  269. // padding-top: 20rpx;
  270. }
  271. .btn {
  272. display: flex;
  273. justify-content: center;
  274. position: fixed;
  275. bottom: 20rpx;
  276. width: 100%;
  277. .a {
  278. display: flex;
  279. justify-content: center;
  280. align-items: center;
  281. width: 70%;
  282. height: 100rpx;
  283. color: #FFF;
  284. background-color: $uni-color;
  285. border: 1px solid red;
  286. border-radius: 100rpx;
  287. font-size: 30rpx;
  288. }
  289. }
  290. .d{
  291. .item {
  292. background-color: #fff;
  293. display: flex;
  294. padding: 30rpx;
  295. width: 690rpx;
  296. .checkbox {
  297. display: flex;
  298. justify-content: center;
  299. align-items: center;
  300. }
  301. .image {
  302. width: 200rpx;
  303. height: 200rpx;
  304. border-radius: 20rpx;
  305. }
  306. .info {
  307. flex: 1;
  308. .title {
  309. display: flex;
  310. padding: 10rpx 20rpx;
  311. justify-content: space-between;
  312. }
  313. .unit {
  314. font-size: 24rpx;
  315. padding: 10rpx 20rpx;
  316. color: #717171;
  317. display: flex;
  318. align-items: center;
  319. }
  320. .price {
  321. color: $uni-color;
  322. font-size: 24rpx;
  323. padding: 10rpx 20rpx;
  324. display: flex;
  325. justify-content: space-between;
  326. text {
  327. font-weight: 900;
  328. }
  329. }
  330. .wan{
  331. color: $uni-color;
  332. font-size: 26rpx;
  333. padding: 10rpx 20rpx;
  334. }
  335. }
  336. }
  337. }
  338. .action {
  339. width: 700rpx;
  340. position: fixed;
  341. bottom: 20rpx;
  342. left: 25rpx;
  343. background-color: #fff;
  344. height: 130rpx;
  345. border-radius: 65rpx;
  346. box-shadow: 0 0 6rpx 6rpx #00000010;
  347. display: flex;
  348. justify-content: center;
  349. align-items: center;
  350. overflow: hidden;
  351. .icon {
  352. position: relative;
  353. width: 80rpx;
  354. height: 80rpx;
  355. margin: 0 20rpx;
  356. image {
  357. width: 80rpx;
  358. height: 80rpx;
  359. }
  360. .num {
  361. position: absolute;
  362. right: 10rpx;
  363. top: 0rpx;
  364. background-color: $uni-color;
  365. color: #fff;
  366. font-size: 18rpx;
  367. border-radius: 50%;
  368. height: 30rpx;
  369. width: 30rpx;
  370. display: flex;
  371. justify-content: center;
  372. align-items: center;
  373. }
  374. }
  375. .price {
  376. .count {
  377. display: flex;
  378. font-size: 26rpx;
  379. align-items: center;
  380. view {
  381. color: $uni-color;
  382. margin-left: 10rpx;
  383. text {
  384. font-size: 32rpx;
  385. font-weight: 900;
  386. }
  387. }
  388. }
  389. .text {
  390. font-size: 22rpx;
  391. color: #717171;
  392. }
  393. }
  394. .btn2 {
  395. margin-left: auto;
  396. background-color: $uni-color;
  397. height: 100%;
  398. padding: 0 50rpx;
  399. color: #fff;
  400. display: flex;
  401. justify-content: center;
  402. align-items: center;
  403. }
  404. }
  405. }
  406. </style>