paymentCode.vue 7.9 KB

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