page.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <template>
  2. <view>
  3. <!--mine/page/page.wxml-->
  4. <view class="title" v-if="title&&!isHetong">{{ title }}</view>
  5. <view class="" style="padding: 30rpx 30rpx 50rpx;" v-if="isHetong">
  6. <rich-text :nodes="params"></rich-text>
  7. <image style="width: 500rpx;height: 300rpx;" mode="aspectFit" :src="signUrl"></image>
  8. </view>
  9. <view class="content" v-else>
  10. <rich-text :nodes="params"></rich-text>
  11. </view>
  12. </view>
  13. </template>
  14. <script>
  15. // mine/page/page.js
  16. const app = getApp();
  17. const req = require('../../utils/request.js');
  18. const util = require('../../utils/util')
  19. export default {
  20. data() {
  21. return {
  22. title: '',
  23. isXieyi: false, //用户协议
  24. isYinsi: false, //隐私政策
  25. isHetong: false, //合同
  26. params: '',
  27. hetongId: null,
  28. signUrl:null
  29. };
  30. },
  31. components: {},
  32. props: {},
  33. onLoad: function(options) {
  34. this.id = options.id;
  35. if (options.isXieyi) {
  36. this.isXieyi = true;
  37. }
  38. if (options.isYinsi) {
  39. this.isYinsi = true;
  40. }
  41. if (options.isHetong) {
  42. this.isHetong = true;
  43. }
  44. this.title = options.title;
  45. if (options.hetongId) this.hetongId = options.hetongId
  46. // if (this.title) {
  47. // uni.setNavigationBarTitle({
  48. // title: this.title
  49. // });
  50. // }
  51. this.getData();
  52. },
  53. methods: {
  54. getData() {
  55. var that = this;
  56. let url = false;
  57. let form = {};
  58. if (that.isXieyi) {
  59. req.getRequest('/api/other/config', {}, function(res) {
  60. that.params = res.SERVICE_AGREEMENT;
  61. });
  62. } else if (that.isYinsi) {
  63. req.getRequest('/api/other/config', {}, function(res) {
  64. that.params = res.PRIVACY_AGREEMENT;
  65. });
  66. } else if (that.isHetong) {
  67. req.getRequest('/admin/v2/contract/' + this.hetongId, {}, (data)=> {
  68. data.content = data.content.replace(/{partyb}/, data.partyb);
  69. data.content = data.content.replace(/{card_no}/, data.partybCardNo);
  70. data.content = data.content.replace(/{partyb_mobile}/, data.partybPhone);
  71. if(data.leaseStart){
  72. data.leaseStart = data.leaseStart.split('-');
  73. }
  74. data.content = data.content.replace(/{hire_begin}/, data.leaseStart ? data.leaseStart[0] + '年' + data
  75. .leaseStart[1] + '月' + data.leaseStart[2] : '____');
  76. if (data.leaseEnd) {
  77. data.leaseEnd = data.leaseEnd.split('-');
  78. }
  79. let time = '';
  80. data.content = data.content.replace(/{hire_end}/, data.leaseEnd ? data.leaseEnd[0] + '年' +
  81. data.leaseEnd[1] + '月' + data.leaseEnd[2] : '____');
  82. if (data.leaseTime) {
  83. data.leaseTime = this.getTime(data.leaseTime);
  84. if (data.leaseTime[0] == 0 && data.leaseTime[1] == 0) time = '01分钟';
  85. if (data.leaseTime[0] > 0) {
  86. time += data.leaseTime[0] + '小时';
  87. }
  88. if (data.leaseTime[1] >= 0) {
  89. time += data.leaseTime[1] + '分钟';
  90. }
  91. }
  92. data.content = data.content.replace(/{hire_duration}/, time ? time : '____');
  93. data.content = data.content.replace(/{battery_model}/, data.batteryModel);
  94. data.content = data.content.replace(/{battery_num}/, data.batteryNum);
  95. data.content = data.content.replace(/{deposit}/, data.deposit);
  96. data.content = data.content.replace(/{hire_price}/, data.leaseMoney);
  97. data.content = data.content.replace(/{order_sign}/, '');
  98. that.params = data.content;
  99. that.signUrl = data.signUrl;
  100. });
  101. }
  102. },
  103. getTime(time) {
  104. return util.countDown(time);
  105. },
  106. }
  107. };
  108. </script>
  109. <style>
  110. @import './page.css';
  111. </style>