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

439 lines
8.9 KiB

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