paymentCode.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  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. console.log(error);
  171. });
  172. },
  173. showLoading() {
  174. uni.showLoading({
  175. title: '正在生成图片'
  176. });
  177. },
  178. hideLoading() {
  179. uni.hideLoading();
  180. this.loading = false;
  181. },
  182. recommendCode() {
  183. this.recommendImg = QR.createQrCodeImg(this.info.qrcode, {
  184. size: parseInt(500) //二维码大小
  185. })
  186. },
  187. }
  188. }
  189. </script>
  190. <script module="canvasImage" lang="renderjs">
  191. import html2canvas from 'html2canvas'
  192. export default {
  193. data() {
  194. return {
  195. }
  196. },
  197. mounted() {
  198. // #ifdef APP-PLUS
  199. setTimeout(() => {
  200. this.canvasImage.generateImage()
  201. }, 1000);
  202. // #endif
  203. },
  204. methods: {
  205. // #ifdef APP-PLUS
  206. generateImage() {
  207. setTimeout(() => {
  208. this.$ownerInstance.callMethod('showLoading')
  209. const dom = document.getElementById('panelcanvas') // 需要生成图片内容的 dom 节点
  210. html2canvas(dom, {
  211. width: dom.clientWidth, //dom 原始宽度
  212. height: dom.clientHeight,
  213. scrollY: 0, // html2canvas默认绘制视图内的页面,需要把scrollY,scrollX设置为0
  214. scrollX: 0,
  215. useCORS: true, //支持跨域
  216. // allowTaint: false,
  217. scale: 3, // 设置生成图片的像素比例,默认是1,如果生成的图片模糊的话可以开启该配置项
  218. }).then((canvas) => {
  219. // 生成成功
  220. this.$ownerInstance.callMethod('hideLoading')
  221. this.$ownerInstance.callMethod('receiveRenderData', canvas.toDataURL('image/png'))
  222. }).catch(err => {
  223. console.log('323213213123_errAlert', `【生成图片失败,请重试】${err}`);
  224. // 生成失败 弹出提示弹窗
  225. this.$ownerInstance.callMethod('_errAlert', `【生成图片失败,请重试】${err}`)
  226. })
  227. }, 300)
  228. }
  229. // #endif
  230. },
  231. }
  232. </script>
  233. <style lang="scss" scoped>
  234. .page {
  235. background-color: #F8F8F8;
  236. height: 100vh;
  237. }
  238. .page {
  239. position: relative;
  240. background-color: #f8f8f8;
  241. }
  242. /* 背景图 */
  243. .paymentCode-back {
  244. width: 100%;
  245. height: 492rpx;
  246. position: fixed;
  247. top: 0;
  248. left: 0;
  249. z-index: 0;
  250. }
  251. .header-title {
  252. position: relative;
  253. padding: 0 30rpx;
  254. box-sizing: border-box;
  255. margin: 16rpx 0;
  256. .left {
  257. image {
  258. width: 40rpx;
  259. height: 40rpx;
  260. }
  261. text {
  262. font-size: 36rpx;
  263. color: #333;
  264. font-weight: bold;
  265. }
  266. }
  267. >text {
  268. font-size: 26rpx;
  269. color: rgba(51, 51, 51, 0.7);
  270. }
  271. }
  272. .content {
  273. padding: 0 20rpx;
  274. box-sizing: border-box;
  275. position: relative;
  276. .scroll-content {
  277. height: calc(100vh - 200px);
  278. background: #FFFFFF;
  279. box-shadow: 0rpx 0rpx 16rpx 0rpx rgba(0, 0, 0, 0.05);
  280. border-radius: 20rpx 20rpx 10rpx 10rpx;
  281. padding: 30rpx;
  282. box-sizing: border-box;
  283. overflow: auto;
  284. .view {
  285. font-size: 30rpx;
  286. color: #666;
  287. margin-bottom: 30rpx;
  288. >text:last-child {
  289. color: #333;
  290. font-weight: bold;
  291. width: 65%;
  292. text-align: right;
  293. }
  294. }
  295. .qrCode {
  296. margin-top: 10px;
  297. >text {
  298. font-size: 30rpx;
  299. color: #333;
  300. }
  301. .qr {
  302. width: 290rpx;
  303. height: 290rpx;
  304. margin: 10rpx auto 0;
  305. padding: 10rpx;
  306. box-sizing: border-box;
  307. }
  308. .undoButton {
  309. padding: 13rpx 26rpx;
  310. box-sizing: border-box;
  311. background: rgba(253, 233, 53, 0.2);
  312. border-radius: 58rpx 58rpx 58rpx 58rpx;
  313. border: 1rpx solid #FDE935;
  314. font-size: 30rpx;
  315. color: #1F1F1F;
  316. }
  317. }
  318. }
  319. }
  320. .btn {
  321. width: 100%;
  322. height: 88rpx;
  323. background: #FDE935;
  324. margin: 30rpx auto 0;
  325. border-radius: 58rpx 58rpx 58rpx 58rpx;
  326. font-size: 36rpx;
  327. color: #1F1F1F;
  328. font-weight: bold;
  329. }
  330. </style>