123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706 |
- <template>
- <navBar title="产品详情"></navBar>
- <navBgCar></navBgCar>
- <view class="content-wrap">
- <!-- <view class="ul-item">
- <image style="width: 100%; height: 170rpx; background-color: #eeeeee"
- :src="`${$imgUrl}applyCard/product-bg.png`"></image>
- <view class="item-value">
- <image class="icon-tip" :src="`${$imgUrl}applyCard/wechat.png`"></image>
- <view class="content">
- <view class="title"> {{state.detailsObj.productName}} </view>
- <view style="margin-top: 15rpx" class="tip"> {{state.detailsObj.releaseProduct.remarks}} </view>
- </view>
- <view class="price">
- ¥:{{state.detailsObj.product.oncePrice * 0.01}}
- </view>
- </view>
- </view> -->
- <!-- <view style="margin: 20rpx 0 10rpx 20rpx;font-size: 32rpx;">加购权益列表</view> -->
- <!-- <view class="add_all">
- <uni-swipe-action>
- <uni-swipe-action-item class="del_item" v-for="(item,index) in state.list"
- :right-options="state.options2" :show="item.isOpened" :auto-close="false" @change="change"
- @click="bindClick(index)">
- <view class="content-box">
- <view v-if='item.children' style="display: inline-block;">
- <image :class="item.isShow?'imageChange':'imageDefault'" @click="changeIsShow(index)"
- src="../../static/image/icon-back.png" alt="" srcset=""></image>
- </view>
- <text class="content-text" @tap="setOpened">{{item.productName}}
- ¥{{item.discountPrice * 0.01}}</text>
- <view v-if="item.isShow" class="children" v-for="(itemChild,index) in item.children"
- :key='index'>
- <view>
- <text>{{itemChild.productName}}</text> <text>{{itemChild.discountPrice * 0.01}}</text>
- </view>
- </view>
- </view>
- </uni-swipe-action-item>
-
- </uni-swipe-action>
- </view> -->
-
- <view class="value-wrapper">
- <view class="flex" v-for="(item,index) in state.dataArray">
- <view class="title"> {{item.payName}} </view>
- <view class="value">
- {{ "¥" + item.fee * 0.01 }}
- </view>
- </view>
- <!-- <view class="flex">
- <view class="title"> 产品金额 </view>
- <view class="value">
- {{ "¥" + state.detailsObj.product.oncePrice * 0.01 }}
- </view>
- </view> -->
- <!-- <view class="flex">
- <view class="title"> 加购权益 </view>
- <view class="value">{{ "¥" + state.productMoney }} </view>
- </view> -->
- <view class="flex">
- <view class="title"> 运费 </view>
- <view class="value"> ¥0.00 </view>
- </view>
- <!-- <view class="flex">
- <view class="title"> 优惠券 </view>
- <view class="value"> 暂无优惠券 </view>
- </view>
- <view class="flex">
- <view class="title"> 积分兑换 </view>
- <view class="value"> 暂无积分 </view>
- </view> -->
- <view class="flex">
- <view class="title"> 实付款 </view>
- <view class="money">
- {{ "¥" + state.allMoney }}
- </view>
- </view>
-
- <view class="as-layout-horizontal agreement">
- <checkbox-group @change="checkboxChange">
- <checkbox :checked="state.checked" style="transform: scale(0.8)" />我已阅读并同意
- </checkbox-group>
- <a style="color:#007AFF;text-decoration: underline;" @click="downAuthD()">《产品协议》</a>
- </view>
- </view>
-
- <view class="action">
- <button type="default" class="button" @click="savaHandle()">
- {{ "确认办理:¥" + state.allMoney }}
- </button>
- </view>
-
- </view>
- </template>
-
- <script setup lang="ts">
- import {
- onLoad,
- onShow
- } from "@dcloudio/uni-app";
- import {
- reactive,
- ref
- } from "vue";
- import {
- etcQueryProduct,
- addProduct,
- getOpenidApi,
- getAgreementApi,
- PAYDETECTION,
- envs,
- agreementConfirmApi
- } from "@/utils/network/api.js";
- import {
- request
- } from "@/utils/network/request.js";
-
- import {
- stringToJson
- } from "@/utils/network/encryption";
- import {
- fileURL
- } from "@/datas/fileURL.js";
- import navBgCar from "./components/nav-bg-car5";
- import navBar from "@/components/nav-bar/nav-bar2.vue";
-
- import {
- getItem,
- StorageKeys
- } from "@/utils/storage.ts";
- import {
- checkOrderStatus,
- orderPay,
- wechatAppID,
- wechatPayConfigId,
- wechatSecret,
- queryDetails
- } from "@/utils/network/api";
- import {
- confirm,
- msg
- } from "@/utils/utils";
- const imgURL = `${fileURL}image/`;
-
- const savaHandle = () => {
- console.log("state.productId.length", state.productId.length)
- //判断是否有加购权益
- // if (state.productId.length > 0) {
- // queryAddProduct();
- // }
- // uni.showModal({
- // // title: '提示',
- // content: '确定支付',
- // success: function (res) {
- // if (res.confirm) {
- // console.log('用户点击确定');
- // wxPayment();
- // } else if (res.cancel) {
- // console.log('用户点击取消');
- // }
- // }
- // });
- // msg("确定绑定权益产品");
- // wxPayment();
- if (state.typeScanCode == 2) {
- console.log("state.typeScanCode", state.typeScanCode)
- // 扫码进来
- agreementConfirm();
- } else {
- console.log("state.checked", state.checked)
- if (state.checked) {
- uni.navigateTo({
- url: `/subpackage/orders/order_payment?orderId=${state.orderId}&&clientFee=${state.clientFee}&&id=${state.id}&&isValueCard=${state.isValueCard}`,
- });
- } else {
- msg("请勾选协议");
- }
- }
-
- };
- const downAuthD = () => {
- // tools.showLoadingAlert("加载中");
- 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) {
-
- }
- })
- }
- //获取微信小程序openid
- const getOpenID = () => {
- uni.login({
- provider: "weixin",
- success: function (e) {
- getOpenid(e.code);
- // uni.request({
- // url: `https://api.weixin.qq.com/sns/jscode2session?appid=${wechatAppID}&secret=${wechatSecret}&js_code=${e.code}&grant_type=authorization_code`,
- // success: (res: any) => {
- // state.openid = res.data.openid;
- // console.log("state.openid", state.openid);
- // },
- // });
- },
- });
- };
- const getOpenid = (code) => {
- const options = {
- type: 2,
- data: {
- "jsCode": code
- },
- method: "POST",
- showLoading: true,
- };
- // #ifdef MP-WEIXIN
- request(getOpenidApi, options).then((res) => {
- const result = stringToJson(res.bizContent);
- console.log("获取微信小程序openid", result);
- const openidData = stringToJson(result.data);
- state.openid = openidData.openid;
- });
- // #endif
- }
- //唤起微信支付
- const wxPayment = () => {
- // #ifdef MP-WEIXIN
- const options = {
- type: 2,
- data: {
- openid: state.openid,
- productId: state.id,
- orderId: state.orderId,
- payConfigId: wechatPayConfigId,
- },
- method: "POST",
- showLoading: true,
- };
- request(orderPay, options).then((res) => {
- const data = stringToJson(res.bizContent);
- uni.requestPayment({
- provider: "wxpay",
- orderInfo: "",
- timeStamp: data.timestamp,
- nonceStr: data.noncestr,
- package: data.wxPackage ? data.wxPackage : "",
- signType: data.signType,
- paySign: data.sign,
- success: function (e) {
- console.log("支付成功", e);
- checkOrder();
- },
- fail: function (err) {
- // checkOrder();
- confirm(err, () => { }, "支付失败", false);
- },
- });
- });
- // #endif
- };
-
- //支付成功改变订单状态
- const checkOrder = () => {
- const options = {
- type: 2,
- data: {
- orderId: state.orderId,
- payConfigId: wechatPayConfigId,
- },
- method: "POST",
- showLoading: true,
- };
-
- request(checkOrderStatus, options).then((res) => {
- msg("支付成功!");
- var pages = getCurrentPages().length;
- uni.$emit("refreshOrder");
- uni.switchTab({
- url: "/pages/order/order"
- })
- });
- };
- // 协议确认接口
- const agreementConfirm = () => {
- const options = {
- type: 2,
- data: {
- orderId: state.orderId,
- protocol: state.checked ? 1 : 0,
- },
- method: "POST",
- showLoading: true,
- };
- console.log("协议确认接口", options)
- request(agreementConfirmApi, options).then((res) => {
- console.log("确认协议", res)
- msg("协议确认成功");
- return;
- });
- };
- onLoad((option : any) => {
- state.orderId = option.orderId;
- state.isValueCard = option.isValueCard;
- console.log("传递过来的参数", option)
- console.log("查协议", envs[process.env.NODE_ENV].baseUrl)
- // state.clientFee = option.clientFee / 100;
- state.id = option.id;
- getOpenID();
-
- // const data = JSON.parse(decodeURIComponent(option.data));
- // for (var i = 0; i < data.length; i++) {
- // data['isOpened'] = 'node';
- // state.productMoney += data[i]['discountPrice'] / 100;
- // state.productId.push(data[i]['equityId'])
- // }
- // state.list = data;
- // queryDetailsData();
- refresh();
- if (option.url) {
- state.agreeURL = envs[process.env.NODE_ENV].baseUrl + option.url
- state.typeScanCode = option.typeScanCode
- console.log("state.agreeURL", state.agreeURL)
- } else {
- queryAgreement();
- }
- });
-
- const state = reactive({
- openid: "",
- orderId: "",
- clientFee: undefined,
- id: "",
- options2: [{
- text: '删除',
- style: {
- backgroundColor: '#F56C6C'
- }
- }],
- isOpened: 'none',
- list: [],
- productMoney: 0,
- allMoney: 0,
- productId: [],
- // 弹框
- type: 'center',
- msgType: 'success',
- messageText: '这是一条成功提示',
- value: '',
- detailsObj: '',
- isValueCard: "",
- dataArray: [],
- checked: false,
- agreeURL: "",
- typeScanCode: 0,//扫码进来得
- });
- const bindClick = (i) => {
- console.log(i);
- uni.showToast({
- title: "删除成功",
- icon: 'none'
- });
- state.list.splice(i, 1);
- state.productMoney = 0;
- state.productId = [];
- for (var k = 0; k < state.list.length; k++) {
- state.productMoney += state.list[k]['discountPrice'] / 100
- state.productId.push(state.list[k]['equityId'])
- }
- state.allMoney = (state.productMoney + state.clientFee).toFixed(2)
- console.log("state.productId", state.productId)
- };
- const setOpened = () => {
- if (state.isOpened === 'none') {
- state.isOpened = 'right';
- return;
- }
- if (state.isOpened === 'left') {
- state.isOpened = 'right';
- return;
- }
- if (state.isOpened === 'right') {
- state.isOpened = 'none';
- return;
- }
- }
- const change = (e) => {
- state.isOpened = e;
- }
- // 加购权益产品接口
- const queryAddProduct = () => {
- console.log("state.openid", state.openid);
- const options = {
- type: 2,
- data: {
- orderId: state.orderId, //订单编号
- openId: state.openid, //操作人 id
- equityId: state.productId.toString(), //权益Id
- totalAmount: state.allMoney * 100, //总金额
- isRepeatPurchase: 0
- },
- method: "POST",
- showLoading: true,
- };
- request(addProduct, options).then((res) => { });
- }
- const changeIsShow = (index) => {
- console.log(index, state.list[index]['isShow'], !state.list[index]['isShow'])
- state.list[index]['isShow'] = !state.list[index]['isShow']
- console.log("state.list", state.list)
- }
- const queryDetailsData = () => {
- const options = {
- type: 2,
- data: {
- orderId: state.orderId, //订单编号
- },
- method: "POST",
- showLoading: true,
- };
- request(queryDetails, options).then((res) => {
- state.detailsObj = stringToJson(res.bizContent);
- console.log("state.detailsObj", state.detailsObj)
- state.allMoney = (parseFloat(state.detailsObj.product.oncePrice * 0.01) + parseFloat(state.productMoney)).toFixed(2)
- });
- }
- // 查协议
- const queryAgreement = () => {
- const options = {
- type: 2,
- data: {
- orderId: state.orderId, //订单编号
- },
- method: "POST",
- showLoading: true,
- };
- request(getAgreementApi, options).then((res) => {
- let data = stringToJson(res.bizContent);
- state.agreeURL = envs[process.env.NODE_ENV].baseUrl + data.supAgree
- console.log("查协议", envs[process.env.NODE_ENV].baseUrl)
- });
- }
- const checkboxChange = (e) => {
- state.checked = !state.checked;
- console.log(state.checked);
- };
- const refresh = () => {
- let source = ""
- // #ifdef MP-ALIPAY
- source = "ALI"
- // #endif
- // #ifdef MP-WEIXIN
- source = "WECHAT"
- // getOpenID();
- // #endif
- var data = {
- orderId: state.orderId,
- source: source //请求方来源
- };
- const options = {
- type: 2,
- data: data,
- method: "POST",
- showLoading: true,
- };
- console.log("输出内容", options);
- request(PAYDETECTION, options).then((res) => {
- // console.log(res.bizContent);
- const data = stringToJson(res.bizContent);
- console.log(data);
- // console.log(typeof(data));
- // if (data.paymentStatus == 'ALLSUCCESS') {
- // gotoEditUserOrUnitInfo()
- // }
- state.dataArray = data.datas;
- // HANDLE("办理费",1){},
- // MARGIN("保证金",2){},
- // PRESTORE("预存金",3){},
- // EQUITY("权益费",4){},
- for (let i = 0; i < state.dataArray.length; i++) {
- // if (state.dataArray[i].payType === 'HANDLE') {
- // state.dataArray[i].payName = '办理费'
- // } else
- if (state.dataArray[i].payType === 'MARGIN') {
- state.dataArray[i].payName = '保证金'
- } else if (state.dataArray[i].payType === 'PRESTORE') {
- state.dataArray[i].payName = '预存金'
- } else if (state.dataArray[i].payType === 'EQUITY') {
- state.dataArray[i].payName = '权益费'
- } else {
- state.dataArray[i].payName = '未知费'
- }
- // SUCCESS("支付成功",1){},
- // PAYING("支付中",2){},
- // FAILED("支付失败",3){},
- // UNPAY("未支付",4){},
- // CLOSED("已关闭",5){},
- // CANCELED("已撤销",6){},
- // REFUND("转入退费",7){},
- if (state.dataArray[i].payStatus === 'SUCCESS') {
- state.dataArray[i].payStatusName = '已支付'
- } else if (state.dataArray[i].payStatus === 'PAYING') {
- state.dataArray[i].payStatusName = '支付中'
- } else if (state.dataArray[i].payStatus === 'FAILED') {
- state.dataArray[i].payStatusName = '支付失败'
- } else if (state.dataArray[i].payStatus === 'UNPAY') {
- state.dataArray[i].payStatusName = '未支付'
- } else if (state.dataArray[i].payStatus === 'CLOSED') {
- state.dataArray[i].payStatusName = '已关闭'
- } else if (state.dataArray[i].payStatus === 'CANCELED') {
- state.dataArray[i].payStatusName = '已撤销'
- } else if (state.dataArray[i].payStatus === 'REFUND') {
- state.dataArray[i].payStatusName = '转入退费'
- } else {
- state.dataArray[i].payStatusName = '未知'
- }
- state.allMoney += state.dataArray[i]["fee"] * 0.01
- }
- console.log("state.dataArray", state.dataArray)
- });
- }
- </script>
-
- <style lang="scss" scoped>
- .action {
- margin-top: 40rpx;
- padding-left: 20rpx;
- padding-right: 20rpx;
- padding-bottom: 30rpx;
-
- .button {
- height: 80rpx;
- background: linear-gradient(-90deg, #43a1e0 0%, #13e7c1 100%);
- border-radius: 40rpx;
- font-size: 32rpx;
- font-weight: 400;
- color: #ffffff;
- line-height: 80rpx;
- }
- }
-
- .value-wrapper {
- margin-top: 40rpx;
- padding: 0rpx 30rpx;
-
- .flex {
- padding: 20rpx 0rpx;
- display: flex;
- justify-content: space-between;
- align-items: center;
-
- .title {
- font-size: 28rpx;
- font-family: Microsoft YaHei;
- font-weight: 400;
- color: #777777;
- line-height: 28rpx;
- }
-
- .value {
- font-size: 28rpx;
- font-family: Microsoft YaHei;
- font-weight: 400;
- color: #333333;
- line-height: 28rpx;
- }
-
- .money {
- font-size: 36rpx;
- font-family: Microsoft YaHei;
- font-weight: 400;
- color: #00b38b;
- line-height: 36rpx;
- }
- }
- }
-
- .content-wrap {
- position: relative;
- margin-top: -50rpx;
- padding: 0rpx 30rpx;
-
- .ul-item {
- padding: 5px 20rpx;
- display: flex;
- align-items: center;
-
- .item-value {
- padding: 20rpx;
- position: absolute;
- display: flex;
- align-items: center;
- // justify-content: space-around;
- width: 80%;
-
- .content {
- width: 48%;
-
- .title {
- font-size: 32rpx;
- font-family: Microsoft YaHei;
- font-weight: 400;
- color: #ffffff;
- }
-
- .tip {
- font-size: 24rpx;
- font-family: Microsoft YaHei;
- font-weight: 400;
- color: #ffffff;
- }
- }
- }
-
- .icon-tip {
- width: 100rpx;
- height: 100rpx;
- }
-
- .content {
- margin-left: 40rpx;
- }
- }
- }
-
- .del_item {
- background-color: rgb(41, 199, 207) !important;
- }
-
- .content-box {
- background-color: rgb(41, 199, 207);
- line-height: 80rpx;
- color: white;
- font-size: 32rpx;
- border-radius: 10rpx 0 0 10rpx;
- padding: 20rpx;
- box-sizing: border-box;
- }
-
- ::v-deep.uni-swipe_button-text {
- font-size: 30rpx !important;
- }
-
- ::v-deep.uni-swipe_button-group {
- font-size: 28rpx !important;
- }
-
- .add_all {
- width: 95%;
- margin: 0 auto;
- }
-
- .uni-swipe_box {
- margin-bottom: 16rpx !important;
- }
-
- ::v-deep.uni-swipe {
- margin-bottom: 16rpx !important;
- }
-
- .imageDefault {
- height: 40rpx;
- width: 40rpx;
- transform: rotate(270deg);
- margin-right: 12rpx;
- color: white;
- }
-
- .imageChange {
- height: 40rpx;
- width: 40rpx;
- transform: rotate(90deg);
- margin-right: 12rpx;
- color: white;
- }
-
- .price {
- color: white;
- }
-
- .agreement {
- font-size: 30rpx;
- display: flex;
- flex-wrap: wrap;
- margin-top: 20rpx;
- align-items: center;
- }
- </style>
|