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

447 lines
9.4 KiB

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