tenancyReletOrder.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447
  1. <template>
  2. <zj-page-layout :hasFooter="true">
  3. <view class="all-container">
  4. <view class="address-container card">
  5. <view class="main">
  6. <view class="left">
  7. <view class="icon"><text class="iconfont icon-dingwei1"></text></view>
  8. <view class="hasdata">
  9. <view class="name">{{addressInfo.name}}<text>{{addressInfo.phone}}</text></view>
  10. <view class="address ellipsis-2">
  11. {{addressInfo.province}}{{addressInfo.city}}{{addressInfo.area}}{{addressInfo.street}}{{addressInfo.address}}{{addressInfo.houseNo}}
  12. </view>
  13. </view>
  14. </view>
  15. </view>
  16. </view>
  17. <view class="card goods">
  18. <view class="common-title">产品信息</view>
  19. <view class="item">
  20. <image :src="product.categoryUrl" mode="aspectFill"></image>
  21. <view class="right">
  22. <view class="name">{{product.goodsLeaseName}}</view>
  23. <view class="name remark">{{product.repairRemark}}</view>
  24. </view>
  25. </view>
  26. <view class="items">
  27. <view class="label">下单日期</view>
  28. <view class="value">{{detail.createTime}}</view>
  29. </view>
  30. <view class="items">
  31. <view class="label">租赁时间</view>
  32. <view class="value">{{product.startDate.substring(0,10) + ' 至 ' + product.endDate.substring(0,10)}}</view>
  33. </view>
  34. <view class="items">
  35. <view class="label"><text>*</text>续租结束日期</view>
  36. <view class="picker" @tap="isShowDate = true">
  37. <text class="value" v-if="endDate">{{endDate}}</text>
  38. <text class="placeholder" v-else>请选择</text>
  39. <text class="iconfont icon-jinru"></text>
  40. </view>
  41. </view>
  42. <view class="items">
  43. <view class="label">续租价格/月</view>
  44. <view class="value">¥{{product.renewalPrice}}</view>
  45. </view>
  46. <view class="items">
  47. <view class="label">续租总金额</view>
  48. <view class="value">¥{{totalPrice}}</view>
  49. </view>
  50. </view>
  51. <view class="card service-container">
  52. <view class="common-title">备注信息</view>
  53. <u--textarea v-model="remark" placeholder="请输入内容" border="none" height="100"></u--textarea>
  54. </view>
  55. </view>
  56. <template slot="footer">
  57. <view class="footer">
  58. <view class="flex_asb">
  59. <view class="left flex_asb">
  60. <text style="color: #666666;font-size: 28rpx;">续租总金额</text>
  61. <text style="color: #ff5300;">¥{{totalPrice}}</text>
  62. </view>
  63. <u-button text="确定续租" shape="circle" color="#428dff" type="primary" @click="submitData"></u-button>
  64. </view>
  65. </view>
  66. </template>
  67. <!-- <zjDialogDatePicker :value="isShowDate" @cancel="cancelDate()"></zjDialogDatePicker> -->
  68. <u-datetime-picker
  69. :show="isShowDate"
  70. v-model="datePickerValue"
  71. mode="date"
  72. :formatter="formatter"
  73. @cancel="isShowDate = false"
  74. @close="isShowDate = false"
  75. @confirm="confirmDate"
  76. :minDate="minDate"
  77. ></u-datetime-picker>
  78. </zj-page-layout>
  79. </template>
  80. <script>
  81. import { weixinPay, mini_env } from '@/common/utils/util.js';
  82. import zjDialogDatePicker from '@/components/zj-dialog/zj-dialog-datePicker.vue';
  83. export default {
  84. components: {
  85. zjDialogDatePicker
  86. },
  87. data() {
  88. return {
  89. detail: {},
  90. addressInfo: null,
  91. isShowDate: false,
  92. is_confirm: true,
  93. userInfo: {},
  94. product: {},
  95. endDate: '',
  96. qty: 1,
  97. totalPrice: 0,
  98. payType: 'WECHAT',
  99. remark: '',
  100. datePickerValue: Number(new Date()),
  101. minDate: Number(new Date()),
  102. }
  103. },
  104. computed: {
  105. },
  106. async onLoad({id}) {
  107. this.id = id
  108. this.getDetail(id)
  109. this.crossPage.$on('confirm', result => {
  110. this.endDate = result.choosDate
  111. console.log(111)
  112. if(result.choosDate){
  113. console.log(111)
  114. this.computePrice()
  115. }
  116. this.isShowDate = false
  117. })
  118. },
  119. onUnload() {
  120. this.crossPage.$off('chooseAddress');
  121. },
  122. methods: {
  123. formatter(type, value) {
  124. if (type === 'year') {
  125. return `${value}年`
  126. }
  127. if (type === 'month') {
  128. return `${value}月`
  129. }
  130. if (type === 'day') {
  131. return `${value}日`
  132. }
  133. return value
  134. },
  135. confirmDate(e) {
  136. this.isShowDate = false;
  137. let time = new Date(e.value);
  138. let y = time.getFullYear();
  139. let m = (time.getMonth()+1) < 10 ? '0' + (time.getMonth()+1) : time.getMonth()+1;
  140. let d = (time.getDate()) < 10 ? '0' + (time.getDate()) : time.getDate();
  141. let hh = (time.getHours()) < 10 ? '0' + (time.getHours()) : time.getHours();
  142. let mm = (time.getMinutes()) < 10 ? '0' + (time.getMinutes()) : time.getMinutes();
  143. let ss = (time.getSeconds()) < 10 ? '0' + (time.getSeconds()) : time.getSeconds();
  144. this.endDate = `${y}-${m}-${d}`;
  145. this.computePrice(`${y}-${m}-${d} 00:00:00'`)
  146. },
  147. // 获取品牌列表
  148. getDetail(id) {
  149. this.$api.post('/lease/order/detail',{
  150. id
  151. }).then(res => {
  152. this.getAddressData(res.data.userAddressId)
  153. this.detail = res.data;
  154. this.product = res.data.items[0]
  155. })
  156. },
  157. // 获取地址信息
  158. getAddressData(userAddressId) {
  159. this.$api.get('/user/address/detail', {
  160. userAddressId
  161. }).then(res => {
  162. this.addressInfo = {
  163. name: res.data.name,
  164. phone: res.data.phone,
  165. province: res.data.province,
  166. city: res.data.city,
  167. area: res.data.area,
  168. street: res.data.street,
  169. address: res.data.address,
  170. houseNo: res.data.houseNo,
  171. defaultAddr: res.data.defaultAddr,
  172. }
  173. })
  174. },
  175. computePrice(endDate){
  176. this.$api.post('/lease/order/compute/renewal/amount', {
  177. id: this.id,
  178. endDate
  179. }).then(res => {
  180. this.totalPrice = res.data
  181. })
  182. },
  183. cancelDate(){
  184. this.isShowDate = false
  185. },
  186. // 去选择地址
  187. chooseAddress() {
  188. this.$navToPage({
  189. url: '/packageMine/pages/address/list?isChoose=' + true
  190. })
  191. },
  192. submitData() {
  193. if (!this.endDate) return this.$toast('请选择续租结束日期');
  194. if (!this.is_confirm) { return this.$toast('请勿频繁点击!') }
  195. this.is_confirm = false
  196. setTimeout(() => {
  197. this.is_confirm = true
  198. }, 3000)
  199. this.workerPay()
  200. },
  201. //代客支付
  202. workerPay() {
  203. mini_env((bool) => {
  204. const that = this
  205. this.$api.post('/lease/order/pay', {
  206. id: this.id,
  207. endDate: this.endDate + ' 00:00:00',
  208. remark: this.remark,
  209. ...(() => {
  210. if (bool) {
  211. return {
  212. miniPay: true,
  213. openId: this.$store.state.user.miniOpenId
  214. }
  215. }
  216. return {}
  217. })()
  218. }).then((res) => {
  219. if (!res.data) return false;
  220. if (bool) {
  221. uniWebview.navigateTo({
  222. url: `/pages/pay/zhupin?${Object.entries({
  223. ...res.data,
  224. payPackage: res.data.payPackage.split("=")[0] || "",
  225. payPackageVal: res.data.payPackage.split("=")[1] || ""
  226. }).map(item => item.join("=")).join("&")}`
  227. })
  228. } else {
  229. weixinPay(res.data, function (res) {
  230. that.$successToast('支付成功');
  231. setTimeout(() => {
  232. that.$navToPage({
  233. url: `/packageWorkorder/pages/tenancyOrderList`
  234. }, 'redirectTo')
  235. }, 1000)
  236. })
  237. }
  238. })
  239. })
  240. },
  241. },
  242. }
  243. </script>
  244. <style lang="scss" scoped>
  245. .all-container{
  246. padding: 0 20rpx 20rpx;
  247. box-sizing: border-box;
  248. }
  249. .card {
  250. @include zj-card;
  251. margin-top: 20rpx;
  252. padding: 30rpx;
  253. }
  254. .flex{
  255. display: flex;
  256. }
  257. .flex_asb{
  258. display: flex;
  259. justify-content: space-between;
  260. align-items: center;
  261. }
  262. .common-title {
  263. font-size: 32rpx;
  264. font-weight: 500;
  265. margin-bottom: 20rpx;
  266. text {
  267. color: $error-color;
  268. font-weight: normal;
  269. }
  270. }
  271. .service-container {
  272. .item {
  273. display: flex;
  274. align-items: center;
  275. justify-content: space-between;
  276. height: 50rpx;
  277. margin-bottom: 30rpx;
  278. .label {
  279. margin-right: 30rpx;
  280. text {
  281. color: $error-color;
  282. }
  283. }
  284. .picker {
  285. .placeholder {
  286. color: $sec-font;
  287. }
  288. .iconfont {
  289. margin-left: 12rpx;
  290. color: $sec-font;
  291. }
  292. }
  293. }
  294. }
  295. .address-container {
  296. .main {
  297. display: flex;
  298. justify-content: space-between;
  299. align-items: center;
  300. margin-top: 30rpx;
  301. }
  302. .right {
  303. font-size: 32rpx;
  304. color: $sec-font;
  305. flex-shrink: 0;
  306. }
  307. .left {
  308. display: flex;
  309. align-items: center;
  310. margin-right: 20rpx;
  311. .icon {
  312. width: 52rpx;
  313. height: 52rpx;
  314. border-radius: 50%;
  315. background: $theme-color;
  316. display: flex;
  317. flex-shrink: 0;
  318. justify-content: center;
  319. align-items: center;
  320. margin-right: 20rpx;
  321. .iconfont {
  322. font-size: 36rpx;
  323. color: #ffffff;
  324. }
  325. }
  326. .nodata {
  327. font-size: 28rpx;
  328. color: #999999;
  329. }
  330. .hasdata {
  331. .name {
  332. font-size: 32rpx;
  333. color: #333333;
  334. text {
  335. color: #999999;
  336. font-size: 28rpx;
  337. margin-left: 16rpx;
  338. }
  339. }
  340. .address {
  341. font-size: 28rpx;
  342. color: #666666;
  343. line-height: 34rpx;
  344. margin-top: 10rpx;
  345. }
  346. }
  347. }
  348. }
  349. .goods{
  350. .item{
  351. display: flex;
  352. align-items: center;
  353. box-sizing: border-box;
  354. image {
  355. width: 140rpx;
  356. height: 140rpx;
  357. margin-right: 20rpx;
  358. }
  359. .right{
  360. flex: 1;
  361. .name{
  362. font-weight: bold;
  363. color: #000000;
  364. font-size: 32rpx;
  365. line-height: 40rpx;
  366. margin-bottom: 20rpx;
  367. }
  368. .remark{
  369. font-size: 26rpx;
  370. color: #59a7ff;
  371. }
  372. .qty{
  373. display: flex;
  374. justify-content: flex-end;
  375. }
  376. }
  377. }
  378. .items {
  379. display: flex;
  380. align-items: center;
  381. justify-content: space-between;
  382. height: 50rpx;
  383. margin-bottom: 30rpx;
  384. .label {
  385. margin-right: 30rpx;
  386. text {
  387. color: $error-color;
  388. }
  389. }
  390. .picker {
  391. .placeholder {
  392. color: $sec-font;
  393. }
  394. .iconfont {
  395. margin-left: 12rpx;
  396. color: $sec-font;
  397. }
  398. }
  399. }
  400. }
  401. .footer{
  402. background-color: #ffffff;
  403. padding: 20rpx;
  404. box-sizing: border-box;
  405. .tip{
  406. background-color: #fffdef;
  407. color: #ff5300;
  408. font-size: 28rpx;
  409. padding: 20rpx 0;
  410. }
  411. .left{
  412. width: 370rpx;
  413. margin-right: 60rpx;
  414. }
  415. }
  416. </style>