paymentCode.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  1. <template>
  2. <view class='page'>
  3. <view class="" id="panelcanvas">
  4. <image class="paymentCode-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="insCompanyVo.logo" mode=""></image>
  10. <text class="ml-1">保险公司</text>
  11. </view>
  12. <text>{{info.createTime}}</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. <!-- #ifdef APP-PLUS -->
  70. <view class="undoButton mt-3">
  71. 撤销二维码
  72. </view>
  73. <!-- #endif -->
  74. </view>
  75. </view>
  76. </view>
  77. </view>
  78. <!-- #ifdef APP-PLUS -->
  79. <view class="" style="padding: 0 20rpx;box-sizing: border-box;">
  80. <view class="btn mt-3 dis a-c j-c " @click="sendPayCode">
  81. 分享
  82. </view>
  83. </view>
  84. <!-- #endif -->
  85. <!-- 自定义加载动画 -->
  86. <global-loading :show="loadingShow" :text="loadingText"></global-loading>
  87. </view>
  88. </template>
  89. <script>
  90. import {
  91. mapState
  92. } from "vuex"
  93. import {
  94. turnBase64Image
  95. } from '@/plugins/utils.js';
  96. import {
  97. pathToBase64,
  98. base64ToPath
  99. } from '@/common/pdf.js'
  100. import QR from "@/common/wxqrcode.js"
  101. export default {
  102. data() {
  103. return {
  104. loadingText: '支付码加载中', //加载提示文字
  105. loadingShow: false,
  106. detailbackimg: "", //背景图
  107. recommendImg: '', //二维码图片
  108. payImg: "",
  109. posterUrl: "",
  110. info: {},
  111. insCompanyVo: {}, //保险公司信息
  112. }
  113. },
  114. onShow() {
  115. },
  116. async mounted() {
  117. this.detailbackimg = await turnBase64Image('/static/image/detailback.png');
  118. },
  119. async onLoad(options) {
  120. this.loadingShow = true;
  121. try {
  122. if (options.ordersNo) {
  123. let res = await this.$http.get('/order/qrCode/getQrCode?orderNo=' + encodeURIComponent(options
  124. .ordersNo))
  125. if (res.code == '200') {
  126. this.info = res.data;
  127. let res1 = await this.$http.get('/supplementOrder/getOrderDetail?ordersNo=' + options
  128. .ordersNo);
  129. if (res1.code == "200") {
  130. this.insCompanyVo = res1.data.insCompanyVo[0];
  131. }
  132. } else {
  133. uni.showToast({
  134. title: res.msg,
  135. icon: "none"
  136. })
  137. }
  138. this.recommendCode();
  139. } else {
  140. uni.showToast({
  141. icon: 'none',
  142. title: '订单号为空'
  143. })
  144. }
  145. this.loadingShow = false;
  146. } catch (error) {
  147. this.loadingShow = false;
  148. }
  149. },
  150. methods: {
  151. //分享图片到微信
  152. sendPayCode() {
  153. if (this.payImg) {
  154. uni.share({
  155. provider: "weixin",
  156. scene: "WXSceneSession",
  157. type: 2,
  158. imageUrl: this.payImg
  159. })
  160. }
  161. },
  162. //页面截图转路径
  163. receiveRenderData(val) {
  164. this.posterUrl = val.replace(/[\r\n]/g, ''); // 去除base64位中的空格
  165. const imageStr = this.posterUrl;
  166. // 将base64转化为临时地址
  167. base64ToPath(imageStr).then(path => {
  168. this.payImg = path
  169. }).catch(error => {});
  170. },
  171. showLoading() {
  172. uni.showLoading({
  173. title: '正在生成图片'
  174. });
  175. },
  176. hideLoading() {
  177. uni.hideLoading();
  178. this.loading = false;
  179. },
  180. recommendCode() {
  181. this.recommendImg = QR.createQrCodeImg(this.info.qrcode, {
  182. size: parseInt(500) //二维码大小
  183. })
  184. },
  185. }
  186. }
  187. </script>
  188. <script module="canvasImage" lang="renderjs">
  189. import html2canvas from 'html2canvas'
  190. export default {
  191. data() {
  192. return {
  193. }
  194. },
  195. mounted() {
  196. // #ifdef APP-PLUS
  197. setTimeout(() => {
  198. this.canvasImage.generateImage()
  199. }, 1000);
  200. // #endif
  201. },
  202. methods: {
  203. // #ifdef APP-PLUS
  204. generateImage() {
  205. setTimeout(() => {
  206. this.$ownerInstance.callMethod('showLoading')
  207. const dom = document.getElementById('panelcanvas') // 需要生成图片内容的 dom 节点
  208. html2canvas(dom, {
  209. width: dom.clientWidth, //dom 原始宽度
  210. height: dom.clientHeight,
  211. scrollY: 0, // html2canvas默认绘制视图内的页面,需要把scrollY,scrollX设置为0
  212. scrollX: 0,
  213. useCORS: true, //支持跨域
  214. // allowTaint: false,
  215. scale: 3, // 设置生成图片的像素比例,默认是1,如果生成的图片模糊的话可以开启该配置项
  216. }).then((canvas) => {
  217. // 生成成功
  218. this.$ownerInstance.callMethod('hideLoading')
  219. this.$ownerInstance.callMethod('receiveRenderData', canvas.toDataURL('image/png'))
  220. }).catch(err => {
  221. // 生成失败 弹出提示弹窗
  222. this.$ownerInstance.callMethod('_errAlert', `【生成图片失败,请重试】${err}`)
  223. })
  224. }, 300)
  225. }
  226. // #endif
  227. },
  228. }
  229. </script>
  230. <style lang="scss" scoped>
  231. .page {
  232. background-color: #F8F8F8;
  233. height: 100vh;
  234. }
  235. .page {
  236. position: relative;
  237. background-color: #f8f8f8;
  238. }
  239. /* 背景图 */
  240. .paymentCode-back {
  241. width: 100%;
  242. height: 492rpx;
  243. position: fixed;
  244. top: 0;
  245. left: 0;
  246. z-index: 0;
  247. }
  248. .header-title {
  249. position: relative;
  250. padding: 0 30rpx;
  251. box-sizing: border-box;
  252. margin: 16rpx 0;
  253. .left {
  254. image {
  255. width: 40rpx;
  256. height: 40rpx;
  257. }
  258. text {
  259. font-size: 36rpx;
  260. color: #333;
  261. font-weight: bold;
  262. }
  263. }
  264. >text {
  265. font-size: 26rpx;
  266. color: rgba(51, 51, 51, 0.7);
  267. }
  268. }
  269. .content {
  270. padding: 0 20rpx;
  271. box-sizing: border-box;
  272. position: relative;
  273. .scroll-content {
  274. height: calc(100vh - 200px);
  275. background: #FFFFFF;
  276. box-shadow: 0rpx 0rpx 16rpx 0rpx rgba(0, 0, 0, 0.05);
  277. border-radius: 20rpx 20rpx 10rpx 10rpx;
  278. padding: 30rpx;
  279. box-sizing: border-box;
  280. overflow: auto;
  281. .view {
  282. font-size: 30rpx;
  283. color: #666;
  284. margin-bottom: 30rpx;
  285. >text:last-child {
  286. color: #333;
  287. font-weight: bold;
  288. width: 65%;
  289. text-align: right;
  290. }
  291. }
  292. .qrCode {
  293. margin-top: 10px;
  294. >text {
  295. font-size: 30rpx;
  296. color: #333;
  297. }
  298. .qr {
  299. width: 290rpx;
  300. height: 290rpx;
  301. margin: 10rpx auto 0;
  302. padding: 10rpx;
  303. box-sizing: border-box;
  304. }
  305. .undoButton {
  306. padding: 13rpx 26rpx;
  307. box-sizing: border-box;
  308. background: rgba(253, 233, 53, 0.2);
  309. border-radius: 58rpx 58rpx 58rpx 58rpx;
  310. border: 1rpx solid #FDE935;
  311. font-size: 30rpx;
  312. color: #1F1F1F;
  313. }
  314. }
  315. }
  316. }
  317. .btn {
  318. width: 100%;
  319. height: 88rpx;
  320. background: #FDE935;
  321. margin: 30rpx auto 0;
  322. border-radius: 58rpx 58rpx 58rpx 58rpx;
  323. font-size: 36rpx;
  324. color: #1F1F1F;
  325. font-weight: bold;
  326. }
  327. </style>