paymentCode.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. <template>
  2. <view class='page'>
  3. <view class="" id="panelcanvas">
  4. <image class="back" :src="detailbackimg" mode=""></image>
  5. <uni-NavBar headerTitle="订单付款" background="transparent" :isShared="false" :isSlot="false"
  6. @share="share"></uni-NavBar>
  7. <view class="header-title dis a-c j-s ">
  8. <view class="dis a-c left">
  9. <image :src="detailbackimg" mode=""></image>
  10. <text class="ml-1">保险公司</text>
  11. </view>
  12. <text>2024.02.03 12:20:12</text>
  13. </view>
  14. <view class="content dis f-c">
  15. <view class="scroll-content">
  16. <view class="view dis a-c j-s ">
  17. <text>车主</text>
  18. <text> {{info.ownerName}}</text>
  19. </view>
  20. <view class="view dis a-c j-s ">
  21. <text>车牌号</text>
  22. <text>{{info.licenseNo}}</text>
  23. </view>
  24. <view class="view dis a-c j-s ">
  25. <text>投保人</text>
  26. <text>{{info.policyName}}</text>
  27. </view>
  28. <view class="view dis a-c j-s ">
  29. <text>被保人</text>
  30. <text>{{info.insuredName}} </text>
  31. </view>
  32. <view class="view dis a-c j-s " v-if="info.jqStartTime">
  33. <text>交强险起保时间</text>
  34. <text>{{info.jqStartTime}}</text>
  35. </view>
  36. <view class="view dis a-c j-s " v-if="info.syStartTime">
  37. <text>商业险起保时间</text>
  38. <text>{{info.syStartTime}}</text>
  39. </view>
  40. <view class="view dis a-c j-s " v-if="info.jqPremium">
  41. <text>交强险</text>
  42. <text>¥{{info.jqPremium}}</text>
  43. </view>
  44. <view class="view dis a-c j-s " v-if="info.taxPremium">
  45. <text>车船税</text>
  46. <text>¥{{info.taxPremium}}</text>
  47. </view>
  48. <view class="view dis a-c j-s " v-if="info.syPremium">
  49. <text>商业险</text>
  50. <text>¥{{info.syPremium}}</text>
  51. </view>
  52. <view class="view dis a-c j-s " v-if="info.jyPremium">
  53. <text>驾意险</text>
  54. <text>¥{{info.jyPremium}}</text>
  55. </view>
  56. <view class="view dis a-c j-s ">
  57. <text>合计</text>
  58. <text style="color: #FF540A;">¥{{info.sumPremium}}</text>
  59. </view>
  60. <view class="qrCode dis a-c f-c ">
  61. <view class="qr">
  62. <image :src="recommendImg" mode="widthFix" lazy-load style="width:100%;height: 100%;">
  63. <!-- <image :src="logoImg" mode=""
  64. style="width: 26px;height: 26px;position: absolute;top: 0;left: 0;right: 0;bottom: 0; margin: auto;">
  65. </image> -->
  66. </image>
  67. </view>
  68. <text class="mt-2">支付码当天之内有效</text>
  69. <view class="undoButton mt-3">
  70. 撤销二维码
  71. </view>
  72. </view>
  73. </view>
  74. </view>
  75. </view>
  76. <!-- #ifdef APP-PLUS -->
  77. <view class="" style="padding: 0 20rpx;box-sizing: border-box;">
  78. <view class="btn mt-3 dis a-c j-c " @click="sendPayCode">
  79. 分享
  80. </view>
  81. </view>
  82. <!-- #endif -->
  83. </view>
  84. </template>
  85. <script>
  86. import {
  87. mapState
  88. } from "vuex"
  89. import {
  90. turnBase64Image
  91. } from '@/plugins/utils.js';
  92. import {
  93. pathToBase64,
  94. base64ToPath
  95. } from '@/common/pdf.js'
  96. import QR from "@/common/wxqrcode.js"
  97. export default {
  98. data() {
  99. return {
  100. detailbackimg: "", //背景图
  101. recommendImg: '', //二维码图片
  102. payImg: "",
  103. posterUrl: "",
  104. info: {},
  105. }
  106. },
  107. onShow() {
  108. },
  109. async mounted() {
  110. this.detailbackimg = await turnBase64Image('/static/image/detailback.png');
  111. },
  112. async onLoad(options) {
  113. console.log(options);
  114. if (options.ordersNo) {
  115. let res = await this.$http.get('/order/qrCode/getQrCode?orderNo=' + options.ordersNo)
  116. if (res.code == '200') {
  117. this.info = res.data;
  118. }
  119. }
  120. this.recommendCode();
  121. },
  122. methods: {
  123. //分享图片到微信
  124. sendPayCode() {
  125. console.log(this.payImg);
  126. if (this.payImg) {
  127. uni.share({
  128. provider: "weixin",
  129. scene: "WXSceneSession",
  130. type: 2,
  131. imageUrl: this.payImg
  132. })
  133. }
  134. },
  135. //页面截图转路径
  136. receiveRenderData(val) {
  137. this.posterUrl = val.replace(/[\r\n]/g, ''); // 去除base64位中的空格
  138. const imageStr = this.posterUrl;
  139. // 将base64转化为临时地址
  140. base64ToPath(imageStr).then(path => {
  141. this.payImg = path
  142. }).catch(error => {
  143. console.log(error);
  144. });
  145. },
  146. showLoading() {
  147. uni.showLoading({
  148. title: '正在生成图片'
  149. });
  150. },
  151. hideLoading() {
  152. uni.hideLoading();
  153. this.loading = false;
  154. },
  155. recommendCode() {
  156. this.recommendImg = QR.createQrCodeImg(this.info.qrcode, {
  157. size: parseInt(500) //二维码大小
  158. })
  159. },
  160. }
  161. }
  162. </script>
  163. <script module="canvasImage" lang="renderjs">
  164. import html2canvas from 'html2canvas'
  165. export default {
  166. data() {
  167. return {
  168. }
  169. },
  170. mounted() {
  171. // #ifdef APP-PLUS
  172. setTimeout(() => {
  173. this.canvasImage.generateImage()
  174. }, 1000);
  175. // #endif
  176. },
  177. methods: {
  178. // #ifdef APP-PLUS
  179. generateImage() {
  180. setTimeout(() => {
  181. this.$ownerInstance.callMethod('showLoading')
  182. const dom = document.getElementById('panelcanvas') // 需要生成图片内容的 dom 节点
  183. html2canvas(dom, {
  184. width: dom.clientWidth, //dom 原始宽度
  185. height: dom.clientHeight,
  186. scrollY: 0, // html2canvas默认绘制视图内的页面,需要把scrollY,scrollX设置为0
  187. scrollX: 0,
  188. useCORS: true, //支持跨域
  189. // allowTaint: false,
  190. scale: 3, // 设置生成图片的像素比例,默认是1,如果生成的图片模糊的话可以开启该配置项
  191. }).then((canvas) => {
  192. // 生成成功
  193. this.$ownerInstance.callMethod('hideLoading')
  194. this.$ownerInstance.callMethod('receiveRenderData', canvas.toDataURL('image/png'))
  195. }).catch(err => {
  196. console.log('323213213123_errAlert', `【生成图片失败,请重试】${err}`);
  197. // 生成失败 弹出提示弹窗
  198. this.$ownerInstance.callMethod('_errAlert', `【生成图片失败,请重试】${err}`)
  199. })
  200. }, 300)
  201. }
  202. // #endif
  203. },
  204. }
  205. </script>
  206. <style lang="scss" scoped>
  207. page {
  208. background-color: #f8f8f8;
  209. }
  210. .page {
  211. position: relative;
  212. background-color: #f8f8f8;
  213. }
  214. /* 背景图 */
  215. .back {
  216. width: 100%;
  217. height: 492rpx;
  218. position: fixed;
  219. top: 0;
  220. left: 0;
  221. z-index: 0;
  222. }
  223. .header-title {
  224. position: relative;
  225. padding: 0 30rpx;
  226. box-sizing: border-box;
  227. margin: 16rpx 0;
  228. .left {
  229. image {
  230. width: 40rpx;
  231. height: 40rpx;
  232. }
  233. text {
  234. font-size: 36rpx;
  235. color: #333;
  236. font-weight: bold;
  237. }
  238. }
  239. >text {
  240. font-size: 26rpx;
  241. color: rgba(51, 51, 51, 0.7);
  242. }
  243. }
  244. .content {
  245. padding: 0 20rpx;
  246. box-sizing: border-box;
  247. position: relative;
  248. .scroll-content {
  249. height: calc(100vh - 200px);
  250. background: #FFFFFF;
  251. box-shadow: 0rpx 0rpx 16rpx 0rpx rgba(0, 0, 0, 0.05);
  252. border-radius: 20rpx 20rpx 10rpx 10rpx;
  253. padding: 30rpx;
  254. box-sizing: border-box;
  255. overflow: auto;
  256. .view {
  257. font-size: 30rpx;
  258. color: #666;
  259. margin-bottom: 30rpx;
  260. >text:last-child {
  261. color: #333;
  262. font-weight: bold;
  263. width: 65%;
  264. text-align: right;
  265. }
  266. }
  267. .qrCode {
  268. margin-top: 10px;
  269. >text {
  270. font-size: 30rpx;
  271. color: #333;
  272. }
  273. .qr {
  274. width: 290rpx;
  275. height: 290rpx;
  276. margin: 10rpx auto 0;
  277. padding: 10rpx;
  278. box-sizing: border-box;
  279. }
  280. .undoButton {
  281. padding: 13rpx 26rpx;
  282. box-sizing: border-box;
  283. background: rgba(253, 233, 53, 0.2);
  284. border-radius: 58rpx 58rpx 58rpx 58rpx;
  285. border: 1rpx solid #FDE935;
  286. font-size: 30rpx;
  287. color: #1F1F1F;
  288. }
  289. }
  290. }
  291. }
  292. .btn {
  293. width: 100%;
  294. height: 88rpx;
  295. background: #FDE935;
  296. margin: 30rpx auto 0;
  297. border-radius: 58rpx 58rpx 58rpx 58rpx;
  298. font-size: 36rpx;
  299. color: #1F1F1F;
  300. font-weight: bold;
  301. }
  302. </style>