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

569 lines
12 KiB

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