You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

sign-up.vue 5.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  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. const openidData = stringToJson(result.data);
  100. state.openid = openidData.openid;
  101. setItem("QYorder", state);
  102. });
  103. // #endif
  104. }
  105. const addInterestsList = () => {
  106. uni.navigateTo({
  107. url: `/subpackage/orders/interestsList?orderId=${state.orderId}&&clientFee=${state.clientFee}&&id=${state.id}`
  108. });
  109. }
  110. const savaHandle = () => {
  111. console.log("openid*******", state.openid);
  112. //如果获取openId成功
  113. if (state.openid) {
  114. var data = {
  115. orderId: state.orderId,
  116. subOpenId: state.openid,
  117. };
  118. const options = {
  119. type: 2,
  120. data: data,
  121. method: "POST",
  122. showLoading: true,
  123. };
  124. request(etcQYAction, options).then((res) => {
  125. const data = stringToJson(res.bizContent);
  126. if (data.userState === "UNAUTHORIZED") {
  127. uni.navigateToMiniProgram({
  128. appId: "wxbcad394b3d99dac9",
  129. path: "pages/route/index",
  130. extraData: {
  131. appid: "wxcb1388c809fe25a9",
  132. sub_appid: "wx008c60533388527a",
  133. mch_id: "1500877591",
  134. sub_mch_id: "1622652848",
  135. nonce_str: data.nonceStr,
  136. sign_type: "HMAC-SHA256",
  137. trade_scene: "HIGHWAY",
  138. plate_number: data.plateNumber,
  139. sub_openid: data.subOpenId,
  140. sign: data.sign,
  141. },
  142. success(res) {
  143. console.log(res);
  144. },
  145. complete(res) {
  146. console.log(res);
  147. },
  148. fail(res) {
  149. console.log(res);
  150. // 未成功跳转到车主小程序
  151. },
  152. });
  153. } else if (data.userState === "NORMAL") {
  154. msg("已开通车主服务");
  155. // uni.navigateTo({
  156. // url: `/subpackage/orders/product-detail?orderId=${state.orderId}&&clientFee=${state.clientFee}&&id=${state.id}`,
  157. // });
  158. uni.switchTab({
  159. url: "/pages/order/order"
  160. })
  161. } else if (data.userState === "PAUSED") {
  162. msg("已暂停车主服务");
  163. return;
  164. } else if (data.userState === "OVERDUE") {
  165. msg("用户已开通车主服务,但欠费状态。提示用户还款,请跳转到车主服务");
  166. return;
  167. }
  168. });
  169. } else {
  170. //如果获取openId失败
  171. uni.showToast({
  172. title: "网络异常,请重试!",
  173. icon: "none",
  174. duration: 1000,
  175. });
  176. return;
  177. }
  178. };
  179. </script>
  180. <style lang="scss" scoped>
  181. .action {
  182. margin-top: 40rpx;
  183. padding-left: 20rpx;
  184. padding-right: 20rpx;
  185. padding-bottom: 30rpx;
  186. .button {
  187. height: 80rpx;
  188. background: linear-gradient(-90deg, #43a1e0 0%, #13e7c1 100%);
  189. border-radius: 40rpx;
  190. font-size: 32rpx;
  191. font-weight: 400;
  192. color: #ffffff;
  193. line-height: 80rpx;
  194. }
  195. }
  196. .title {
  197. text-align: center;
  198. margin-top: 15rpx;
  199. font-size: 36rpx;
  200. font-family: Microsoft YaHei;
  201. font-weight: 400;
  202. color: #333333;
  203. line-height: 36rpx;
  204. }
  205. .value {
  206. padding: 0rpx 60rpx;
  207. }
  208. .content_1 {
  209. margin-top: 60rpx;
  210. font-size: 30rpx;
  211. font-family: Microsoft YaHei;
  212. font-weight: 400;
  213. color: #666666;
  214. line-height: 58rpx;
  215. }
  216. .content_2 {
  217. margin-top: 50rpx;
  218. font-size: 30rpx;
  219. font-family: Microsoft YaHei;
  220. font-weight: 400;
  221. color: #666666;
  222. line-height: 58rpx;
  223. }
  224. </style>