123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253 |
- <template>
- <view class="content">
- <view class="item" v-for="(item,index) in state.list" :key='index'>
- <view class="title" @click="addInterestsList(item)">
- <view>
- <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><text>{{item.productName}}</text> <text>¥{{item.discountPrice * 0.01}}</text></text>
- </view>
- <!-- <checkbox-group @change='getValue(index)'>
- <label>
- <checkbox :value="index" />
- </label>
- </checkbox-group> -->
- </view>
- <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>
- <!-- <button type="default" class="button" @click="addInterestsList()">
- 加购权益
- </button> -->
- </view>
- </template>
-
- <script setup lang="ts">
- import { onLoad, onShow } from "@dcloudio/uni-app";
- import { reactive } from "vue";
- import { equityProductsApi } from "@/utils/network/api.js";
- import { stringToJson } from "@/utils/network/encryption";
- import { request } from "@/utils/network/request";
- import { etcQYAction } from "@/utils/network/api.js";
- import { fileURL } from "@/datas/fileURL.js";
- import navBar from "@/components/nav-bar/nav-bar2.vue";
- import navBgCar from "./components/nav-bg-car4";
- // import { setItem } from "@/utils/storage";
- import { msg } from "@/utils/utils";
- import {
- checkOrderStatus,
- wechatAppID,
- wechatPayConfigId,
- wechatSecret,
- addProduct,
- queryDetails,
- getOpenidApi
- } from "@/utils/network/api";
- import {
- getItem,
- StorageKeys,
- setItem
- } from "@/utils/storage";
- const imgURL = `${fileURL}image/`;
-
- const state = reactive({
- openid: "",
- orderId: "",
- id: "",
- clientFee: "",
- list: [], //权益数据
- choiceValue: [], //选择的权益数据的下标
- choiceValueComplete: [], //选择的权益数据的具体数据
- isValueCard: "",
- type: 0,
- userType: 0,
- promoteId: "", //产品id
- totalAmount: 0, //产品+权益产品金额
- })
-
- onLoad((option : any) => {
- // getList("promoteId", option);
- console.log("promoteId", option)
-
- state.orderId = option.orderId;
- state.clientFee = option.clientFee;
- state.id = option.id;
- state.userType = option.userType;
- state.type = option.type;
- state.isValueCard = option.isValueCard;
- state.promoteId = option.promoteId;
- state.totalAmount = option.fee;
- getList();
- getOpenID();
-
- console.log("option", option)
- })
- const addInterestsList = (item) => {
- console.log("item", item)
- state.totalAmount = Number(state.totalAmount) + Number(item.discountPrice)
- uni.redirectTo({
- url: `/subpackage/orders/essential-information?promoteId=${getItem("promoteId")}&userType=${state.userType}&type=${state.type}&isValueCard=${state.isValueCard}&totalAmount=${state.totalAmount}&equityId=${item.equityId}`,
- });
- }
-
-
- const getList = () => {
- const options = {
- type: 2,
- data: {
- "promoteId": state.promoteId,
- },
- method: 'POST',
- showLoading: true,
- }
- request(equityProductsApi, options).then((res) => {
- const data = stringToJson(res.bizContent);
- for (var i = 0; i < data.data.length; i++) {
- data.data[i]['isShow'] = false;
- }
- state.list = data.data
- console.log("222", data.data)
- })
- }
- const change = (e) => {
- console.log(e);
- }
-
- //获取微信小程序openid
- const getOpenID = () => {
- // #ifdef MP-WEIXIN
- uni.login({
- provider: "weixin",
- success: function (e) {
- console.log(e);
- getOpenid(e.code);
- },
- });
- //#endif
- };
- 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;
- setItem("QYorder", state);
- // setItem("QYorder", result.data);
- // state.openid = result.data.openid
- });
- // #endif
- }
- 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 getValue = (value) => {
- if (state.choiceValue.length == 0) {
- console.log("第一次")
- state.choiceValue.push(value)
- console.log("state.choiceValue", state.choiceValue)
- } else {
- var index = state.choiceValue.indexOf(value);
- if (index > -1) {//大于0 代表存在,
- state.choiceValue.splice(index, 1);//存在就删除
- } else {
- state.choiceValue.push(value)
- }
- console.log("state.choiceValue", state.choiceValue)
- }
-
- }
- </script>
-
- <style scoped lang="scss">
- .content {
- width: 100%;
- height: 100vh;
- }
-
- .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;
- margin: 20rpx;
- }
-
- .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;
- }
-
- .item {
- width: 90%;
- margin: 20rpx auto;
- background-color: rgb(41, 199, 207);
- border-radius: 20rpx;
- padding: 20rpx;
- box-sizing: border-box;
- color: white;
- font-size: 32rpx;
-
- }
-
- .item>.title {
- width: 100%;
- display: flex;
- justify-content: space-between;
- align-items: center;
- }
-
- .title>checkbox-group {
- // float: right;
- }
-
- .children {
- margin-left: 50rpx;
- margin-top: 16rpx;
- }
-
- .children>view {
- height: 50rpx;
- line-height: 50rpx;
- }
-
- .show {
- display: inline-block;
- }
-
- .hide {
- display: none;
- }
-
- checkbox {
- transform: scale(0.8);
- }
- </style>
|