選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

sign-up.vue 5.7KB

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