Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

sign-up.vue 4.8KB

2 anos atrás
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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. uni.request({
  77. url: `https://api.weixin.qq.com/sns/jscode2session?appid=${wechatAppID}&secret=${wechatSecret}&js_code=${e.code}&grant_type=authorization_code`,
  78. success: (res: any) => {
  79. state.openid = res.data.openid;
  80. setItem("QYorder", state)
  81. console.log(res);
  82. },
  83. });
  84. },
  85. });
  86. };
  87. const savaHandle = () => {
  88. //如果获取openId成功
  89. if (state.openid != '') {
  90. var data = {
  91. orderId: state.orderId,
  92. subOpenId: state.openid,
  93. };
  94. const options = {
  95. type: 2,
  96. data: data,
  97. method: "POST",
  98. showLoading: true,
  99. };
  100. request(etcQYAction, options).then((res) => {
  101. const data = stringToJson(res.bizContent);
  102. console.log(data);
  103. if (data.userState === 'UNAUTHORIZED') {
  104. uni.navigateToMiniProgram({
  105. appId: 'wxbcad394b3d99dac9',
  106. path: 'pages/route/index',
  107. extraData: {
  108. appid: 'wxcb1388c809fe25a9',
  109. sub_appid: 'wx008c60533388527a',
  110. mch_id: '1500877591',
  111. sub_mch_id: '1622652848',
  112. nonce_str: data.nonceStr,
  113. sign_type: 'HMAC-SHA256',
  114. trade_scene: 'HIGHWAY',
  115. plate_number: data.plateNumber,
  116. sub_openid: data.subOpenId,
  117. sign: data.sign,
  118. },
  119. success(res) {
  120. console.log(res);
  121. },
  122. complete(res) {
  123. console.log(res);
  124. },
  125. fail(res) {
  126. console.log(res);
  127. // 未成功跳转到车主小程序
  128. },
  129. });
  130. } else if (data.userState === 'NORMAL') {
  131. msg('已开通车主服务')
  132. uni.navigateTo({
  133. url: `/applyCard/product-detail?orderId=${state.orderId}&&clientFee=${state.clientFee}&&id=${state.id}`,
  134. });
  135. } else if (data.userState === 'PAUSED') {
  136. msg('已暂停车主服务')
  137. return;
  138. } else if (data.userState === 'OVERDUE') {
  139. msg('用户已开通车主服务,但欠费状态。提示用户还款,请跳转到车主服务')
  140. return;
  141. }
  142. });
  143. } else {
  144. //如果获取openId失败
  145. uni.showToast({
  146. title: "网络异常,请重试!",
  147. duration: 500
  148. })
  149. return;
  150. }
  151. };
  152. </script>
  153. <style lang="scss" scoped>
  154. .action {
  155. margin-top: 40rpx;
  156. padding-left: 20rpx;
  157. padding-right: 20rpx;
  158. padding-bottom: 30rpx;
  159. .button {
  160. height: 80rpx;
  161. background: linear-gradient(-90deg, #43a1e0 0%, #13e7c1 100%);
  162. border-radius: 40rpx;
  163. font-size: 32rpx;
  164. font-weight: 400;
  165. color: #ffffff;
  166. line-height: 80rpx;
  167. }
  168. }
  169. .title {
  170. text-align: center;
  171. margin-top: 15rpx;
  172. font-size: 36rpx;
  173. font-family: Microsoft YaHei;
  174. font-weight: 400;
  175. color: #333333;
  176. line-height: 36rpx;
  177. }
  178. .value {
  179. padding: 0rpx 60rpx;
  180. }
  181. .content_1 {
  182. margin-top: 60rpx;
  183. font-size: 30rpx;
  184. font-family: Microsoft YaHei;
  185. font-weight: 400;
  186. color: #666666;
  187. line-height: 58rpx;
  188. }
  189. .content_2 {
  190. margin-top: 50rpx;
  191. font-size: 30rpx;
  192. font-family: Microsoft YaHei;
  193. font-weight: 400;
  194. color: #666666;
  195. line-height: 58rpx;
  196. }
  197. </style>