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

586 lines
12 KiB

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