page.vue 3.2 KB

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