123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406 |
- <template>
- <view class="container">
- <view class="t-card">
- <view class="title">
- <image :src="`${$imgUrl}issuance/title-bg.png`" mode="aspectFit" class='bg'></image>
- <image :src="`${$imgUrl}issuance/bg-xia.png`" mode="aspectFit" class='bg-xia'></image>
- <view class="txt">
- 微信车主服务
- </view>
- </view>
- <view class="value">
- <view class="item">
- <view class="l-icon"></view>
- <view class="r-txt">
- 微信车主服务是微信支付为车主用户提供的安全便捷的智慧服务
- </view>
- </view>
- <view class="item item2">
- <view class="l-icon"></view>
- <view class="r-txt">
- 本次将为贵州黔通智联科技股份有限公司开启免密支付服务,后续相关的费用将通过微信车主服务从你的微信支付账户扣除
- </view>
- </view>
-
- </view>
- </view>
-
- <view class="action">
- <view class="btn-tip">
- <image :src="`${$imgUrl}issuance/note.png`" mode="aspectFit" class="tip-icon"></image>
- 注:签约成功后请返回本页面,再次点击{{state.channelSing=="0"?'开通服务':'恢复签约'}}
- </view>
- <button type="default" class="button" @click="savaHandle()">
- {{state.channelSing=="0"?'开通服务':'恢复签约'}}
- </button>
- </view>
- </view>
- </template>
-
- <script setup lang="ts">
- import { onLoad, onShow } from "@dcloudio/uni-app";
- import { reactive } from "vue";
- import { request, requestNew } from "@/utils/network/request.js";
-
- import { stringToJson } from "@/utils/network/encryption";
- import { fileURL } from "@/datas/fileURL.js";
- import { setItem } from "@/utils/storage";
- import { msg } from "@/utils/utils";
- import {
- infoQuery,
- envs, channelSingQueryApi, userSign, getOpenId
- } from "@/utils/network/api";
- const imgURL = `${fileURL}image/`;
-
- const state = reactive({
- openid: "",
- orderId: "",
- id: "",
- clientFee: "",
- checked: false,
- agreeURL: "",
- channelSing: "0",//0 正常签约 1恢复签约
- vehiclePlate: "",
- code: ""
- });
- onLoad((option : any) => {
- getOpenID();
- state.orderId = option.orderId;
- if (option.channelSing) {
- state.channelSing = option.channelSing;
- }
- console.log("state.channelSing",option.channelSing,option)
- state.vehiclePlate = option.vehiclePlate;
- getInfo();
- });
- const checkboxChange = (e) => {
- state.checked = !state.checked;
- console.log(state.checked);
- };
- const getInfo = () => {
- //参数说明
- let options = {
- type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
- data: {
- businessType: 'WITHHOLD_AGREEMENT' //代扣协议
- }, //请求参数
- method: "POST", //提交方式(默认POST)
- showLoading: true, //是否显示加载中(默认显示)
- };
-
- //调用方式
- requestNew(infoQuery, options)
- .then((res) => {
- let data = res
- if (data.textType = "URL") {
- state.agreeURL = envs[process.env.NODE_ENV].baseUrl + data.text
- }
- console.log("代扣协议", state.agreeURL);
- })
- .catch((err) => {
- console.log(err);
- });
- }
- //获取微信小程序openid
- const getOpenID = () => {
- // #ifdef MP-WEIXIN
- uni.login({
- provider: "weixin",
- success: function (e) {
- console.log(e);
- state.code = e.code
- getOpenid(e.code);
- },
- });
- // #endif
- };
- const downAuthD = () => {
- uni.downloadFile({
- url: state.agreeURL,
- filePath: wx.env.USER_DATA_PATH + '/' + '代扣协议.docx',
- success(res) {
- const filePath = res.filePath
- uni.openDocument({
- filePath: filePath,
- fileType: 'docx',
- showMenu: true, //关键点
- success: function (res) {
- msg("打开文档成功");
- },
- fail: function (err) {
- msg("打开文档失败");
- }
- });
- },
- fail: function (err) {
- msg("下载文档失败");
- console.log("err", err)
- },
- complete(res) {
-
- }
- })
- }
- const getOpenid = (code) => {
- const options = {
- type: 2,
- data: {
- "jsCode": code
- },
- method: "POST",
- showLoading: true,
- };
- // #ifdef MP-WEIXIN
- requestNew(getOpenId, options).then((res) => {
- const result = res;
- const openidData = stringToJson(result.data);
- state.openid = openidData.openid;
- console.log("获取微信小程序openid", state.openid);
- setItem("QYorder", openidData);
- });
- // #endif
- }
- const savaHandle = () => {
- console.log("openid*******", state.openid);
- //如果获取openId成功
- if (state.openid) {
- var data = {
- orderId: state.orderId,
- subOpenId: state.openid,
- };
- const options = {
- type: 2,
- data: data,
- method: "POST",
- showLoading: true,
- };
- requestNew(userSign, options).then((res) => {
- const data = res;
- console.log("data", data)
- if (data.userState === "UNAUTHORIZED") {
- console.log("state.channelSing",state.channelSing,state.channelSing=="0")
- if (state.channelSing == "0") {
- uni.navigateToMiniProgram({
- appId: "wxbcad394b3d99dac9",
- path: "pages/route/index",
- extraData: {
- appid: data.appid,
- sub_appid: data.subAppid,
- mch_id: data.mchId,
- sub_mch_id: data.subMchId,
- nonce_str: data.nonceStr,
- sign_type: data.signType,
- trade_scene: data.tradeScene,
- plate_number: data.plateNumber,
- sub_openid: data.subOpenId,
- sign: data.sign,
- channel_type: data.channelType
- },
- success(res) {
- console.log(res);
- },
- complete(res) {
- console.log(res);
- },
- fail(res) {
- console.log(res);
- // 未成功跳转到车主小程序
- },
- });
- } else {
- // 恢复签约
- const optionss = {
- type: 2,
- data: {
- plateNumber: state.vehiclePlate,
- openid: state.openid,
- channelId: '52010188925',
- tradeScene: 'HIGHWAY',
- code: state.code
- },
- method: "POST",
- showLoading: true,
- };
- requestNew(channelSingQueryApi, optionss)
- .then((res) => {
- let data = res
- uni.navigateToMiniProgram({
- appId: "wxbcad394b3d99dac9",
- path: "pages/route/index",
- extraData: {
- appid: data.appid,
- sub_appid: data.subAppid,
- mch_id: data.mchId,
- sub_mch_id: data.subMchId,
- nonce_str: data.nonceStr,
- sign_type: data.signType,
- trade_scene: data.tradeScene,
- plate_number: data.plateNumber,
- sub_openid: data.subOpenid,
- sign: data.sign,
- channel_type: data.channelType
- },
- success(res) {
-
- },
- complete(res) {
- console.log(res);
- },
- fail(res) {
- console.log(res);
-
- // 未成功跳转到车主小程序
- },
- });
-
- })
- .catch((err) => {
- console.log(err);
- });
- }
-
- } else if (data.userState === "NORMAL") {
- msg("已开通车主服务");
- setTimeout(() => {
- uni.redirectTo({
- url: `/pages/order/order?index=0`
- })
- }, 1500)
-
- } else if (data.userState === "PAUSED") {
- msg("已暂停车主服务");
- return;
- } else if (data.userState === "OVERDUE") {
- msg("用户已开通车主服务,但欠费状态。提示用户还款,请跳转到车主服务");
- return;
- }
- });
- } else {
- //如果获取openId失败
- uni.showToast({
- title: "网络异常,请重试!",
- icon: "none",
- duration: 1000,
- });
- return;
- }
- };
- </script>
-
- <style lang="scss" scoped>
- .container {
- background: #E9EDF0;
- height: 100vh;
- width: 100%;
- position: relative;
- overflow: hidden;
-
- .t-card {
- margin: 30rpx;
- background-color: #fff;
- border-radius: 12rpx;
- padding: 50rpx 30rpx;
- }
- }
-
- .action {
- position: absolute;
- bottom: 0rpx;
- left: 0;
- height: 188rpx;
- background-color: #fff;
- border-radius: 30rpx 30rpx 0 0;
- width: 100vw;
- display: flex;
- align-items: center;
- justify-content: center;
- flex-direction: column;
-
- .btn-tip {
- font-family: SourceHanSansSC, SourceHanSansSC;
- font-weight: 400;
- font-size: 24rpx;
- color: #CCB375;
- margin-bottom: 14rpx;
- display: flex;
- align-items: center;
- .tip-icon{
- width: 26rpx;
- height: 26rpx;
- margin-right: 10rpx;
- }
- }
-
- .button {
- height: 88rpx;
- background: radial-gradient(at 0% 0%, #C6B077 0%, #DFCC96 100%);
- border-radius: 40rpx;
- font-size: 32rpx;
- font-weight: 400;
- color: #ffffff;
- line-height: 88rpx;
- width: 660rpx;
- margin: 0 auto;
- }
- }
-
- .title {
- margin: 0 auto;
- width: 322rpx;
- height: 44rpx;
- position: relative;
-
- .bg {
- width: 322rpx;
- height: 44rpx;
- }
-
- .bg-xia {
- left: 50%;
- position: absolute;
- width: 200rpx;
- height: 8rpx;
- transform: translateX(-50%);
- bottom: 0;
- }
-
- .txt {
- font-family: SourceHanSansSC, SourceHanSansSC;
- font-weight: bold;
- font-size: 36rpx;
- color: #004576;
- position: absolute;
- width: 322rpx;
- text-align: center;
- bottom: 0;
- }
- }
-
- .value {}
-
- .item {
- display: flex;
- margin-top: 60rpx;
- font-size: 28rpx;
- font-family: SourceHanSansSC, SourceHanSansSC;
- font-weight: 400;
- color: #222;
- line-height: 48rpx;
-
- .l-icon {
- margin-top: 20rpx;
- flex-shrink: 0;
- border-radius: 50%;
- height: 10rpx;
- width: 10rpx;
- background-color: #004576;
- margin-right: 18rpx;
-
-
- }
- }
-
- .item2 {
- margin-top: 30rpx;
- }
- </style>
|