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

441 lines
9.1 KiB

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