Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

sign-up.vue 5.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. <template>
  2. <image style="
  3. margin-top: 20rpx;
  4. width: 100%;
  5. height: 240rpx;
  6. background-color: #eeeeee;
  7. " :src="`${$imgUrl}applyCard/car-service.png`"></image>
  8. <view class="title"> 微信车主服务 </view>
  9. <view class="value">
  10. <view class="content_1">
  11. 微信车主服务是微信支付为车主用户提供的安全便捷的智慧服务
  12. </view>
  13. <view class="content_2">
  14. 本次将为贵州黔通智联科技股份有限公司开启免密支付服务,后续相关的费用将通过微信车主服务从你的微信支付账户扣除
  15. </view>
  16. </view>
  17. <view class="action">
  18. <button type="default" class="button" @click="savaHandle()">
  19. 开通服务
  20. </button>
  21. </view>
  22. </template>
  23. <script setup lang="ts">
  24. import {
  25. onLoad,
  26. onShow
  27. } from "@dcloudio/uni-app";
  28. import {
  29. reactive
  30. } from "vue";
  31. import {
  32. etcQYAction
  33. } from "@/utils/network/api.js";
  34. import {
  35. request
  36. } from "@/utils/network/request.js";
  37. import {
  38. stringToJson
  39. } from "@/utils/network/encryption";
  40. import {
  41. fileURL
  42. } from "@/datas/fileURL.js";
  43. import navBar from "../components/nav-bar/nav-bar2.vue";
  44. import navBgCar from "./components/nav-bg-car4";
  45. import {
  46. setItem
  47. } from "@/utils/storage";
  48. import {
  49. msg
  50. } from "@/utils/utils";
  51. import {
  52. checkOrderStatus,
  53. orderPay,
  54. wechatAppID,
  55. wechatPayConfigId,
  56. wechatSecret,
  57. } from "@/utils/network/api";
  58. const imgURL = `${fileURL}image/`;
  59. const state = reactive({
  60. openid: "",
  61. orderId: "",
  62. id: '',
  63. clientFee: ''
  64. });
  65. onLoad((option: any) => {
  66. getOpenID();
  67. state.orderId = option.orderId;
  68. state.clientFee = option.clientFee;
  69. state.id = option.id;
  70. });
  71. //获取微信小程序openid
  72. const getOpenID = () => {
  73. uni.login({
  74. provider: "weixin",
  75. success: function(e) {
  76. console.log(e);
  77. uni.request({
  78. url: `https://api.weixin.qq.com/sns/jscode2session?appid=${wechatAppID}&secret=${wechatSecret}&js_code=${e.code}&grant_type=authorization_code`,
  79. success: (res: any) => {
  80. state.openid = res.data.openid;
  81. setItem("QYorder", state)
  82. console.log(res);
  83. },
  84. fail:(err :any)=>{
  85. uni.showToast({
  86. title: "网络异常,请重试!"+err.errcode,
  87. icon:"error",
  88. duration: 500
  89. })
  90. return;
  91. }
  92. });
  93. },
  94. });
  95. };
  96. const savaHandle = () => {
  97. console.log("openid*******",state.openid);
  98. //如果获取openId成功
  99. if (state.openid) {
  100. var data = {
  101. orderId: state.orderId,
  102. subOpenId: state.openid,
  103. };
  104. const options = {
  105. type: 2,
  106. data: data,
  107. method: "POST",
  108. showLoading: true,
  109. };
  110. request(etcQYAction, options).then((res) => {
  111. const data = stringToJson(res.bizContent);
  112. if (data.userState === 'UNAUTHORIZED') {
  113. uni.navigateToMiniProgram({
  114. appId: 'wxbcad394b3d99dac9',
  115. path: 'pages/route/index',
  116. extraData: {
  117. appid: 'wxcb1388c809fe25a9',
  118. sub_appid: 'wx008c60533388527a',
  119. mch_id: '1500877591',
  120. sub_mch_id: '1622652848',
  121. nonce_str: data.nonceStr,
  122. sign_type: 'HMAC-SHA256',
  123. trade_scene: 'HIGHWAY',
  124. plate_number: data.plateNumber,
  125. sub_openid: data.subOpenId,
  126. sign: data.sign,
  127. },
  128. success(res) {
  129. console.log(res);
  130. },
  131. complete(res) {
  132. console.log(res);
  133. },
  134. fail(res) {
  135. console.log(res);
  136. // 未成功跳转到车主小程序
  137. },
  138. });
  139. } else if (data.userState === 'NORMAL') {
  140. msg('已开通车主服务')
  141. uni.navigateTo({
  142. url: `/applyCard/product-detail?orderId=${state.orderId}&&clientFee=${state.clientFee}&&id=${state.id}`,
  143. });
  144. } else if (data.userState === 'PAUSED') {
  145. msg('已暂停车主服务')
  146. return;
  147. } else if (data.userState === 'OVERDUE') {
  148. msg('用户已开通车主服务,但欠费状态。提示用户还款,请跳转到车主服务')
  149. return;
  150. }
  151. });
  152. } else {
  153. //如果获取openId失败
  154. uni.showToast({
  155. title: "网络异常,请重试!",
  156. icon:"none",
  157. duration: 1000
  158. })
  159. return;
  160. }
  161. };
  162. </script>
  163. <style lang="scss" scoped>
  164. .action {
  165. margin-top: 40rpx;
  166. padding-left: 20rpx;
  167. padding-right: 20rpx;
  168. padding-bottom: 30rpx;
  169. .button {
  170. height: 80rpx;
  171. background: linear-gradient(-90deg, #43a1e0 0%, #13e7c1 100%);
  172. border-radius: 40rpx;
  173. font-size: 32rpx;
  174. font-weight: 400;
  175. color: #ffffff;
  176. line-height: 80rpx;
  177. }
  178. }
  179. .title {
  180. text-align: center;
  181. margin-top: 15rpx;
  182. font-size: 36rpx;
  183. font-family: Microsoft YaHei;
  184. font-weight: 400;
  185. color: #333333;
  186. line-height: 36rpx;
  187. }
  188. .value {
  189. padding: 0rpx 60rpx;
  190. }
  191. .content_1 {
  192. margin-top: 60rpx;
  193. font-size: 30rpx;
  194. font-family: Microsoft YaHei;
  195. font-weight: 400;
  196. color: #666666;
  197. line-height: 58rpx;
  198. }
  199. .content_2 {
  200. margin-top: 50rpx;
  201. font-size: 30rpx;
  202. font-family: Microsoft YaHei;
  203. font-weight: 400;
  204. color: #666666;
  205. line-height: 58rpx;
  206. }
  207. </style>