paymentCode.vue 8.5 KB

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