123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241 |
- <template>
- <view class="selectCar-box">
- <view v-if="state.list" class="item" v-for="(item,i) in state.list" :key="i">
- <view>权益名称:{{item.name}}</view>
- <view>权益金额:¥{{item.fee * 0.01}}元</view>
- <view v-if="item.insertTime">购买时间:{{item.insertTime}}</view>
- <view v-if="item.payTime">支付时间:{{item.payTime}}</view>
- <view style="display: flex;justify-content: flex-end;">
- <text class="btn btn-primary" v-if="item.evaluate==1">已评价</text>
- <text class="btn btn-primary" v-else @click="goQuanyi(item)">去评价</text>
- <!-- 是否支付 1-已支付,2-未支付支付,3-已取消,4-已下单,未支付 -->
- <text class="btn btn-primary" v-if="item.isPay==2"
- @click="equityPaymentOrderRequest(item.id)">去支付</text>
- </view>
- </view>
-
- <view v-else>
- <empty title='暂无权益记录' />
- </view>
- <view style="text-align: center;margin: 20rpx;font-size: 30rpx;" v-if="state.flags">我是有底线的~</view>
-
- </view>
- </template>
-
- <script lang="ts" setup>
- import empty from "@/components/empty/empty.vue";
- import {
- reactive,
- ref
- } from "vue"
- import {
- msg,
- navTo
- } from "@/utils/utils"
- import {
- onLoad, onReachBottom, onShow
- } from "@dcloudio/uni-app";
- import {
- showEquityListApi, getOpenidApi, equityPaymentOrderApi, equityPaymentTestApi
- } from "@/utils/network/api.js";
- import {
- request
- } from "@/utils/network/request.js";
- import {
- getItem,
- StorageKeys,
- } from "@/utils/storage";
- import {
- stringToJson
- } from "@/utils/network/encryption";
-
- const state = reactive({
- list: [],//车辆list,
- equtyId: "",//权益id
- flags: false,
- pageSize: 10,
- pageNo: 1,
- id: ""
- });
- const flag = ref('0') //默认选择0
- onShow(() => {
- state.pageNo = 1
- state.list = []
- showEquityListRequest()
- })
- const showEquityListRequest = () => {
- const options = {
- type: 2,
- data: {
- "openId": getItem(StorageKeys.OpenId),
- "pageNo": state.pageNo,
- "pageSize": state.pageSize,
- },
- method: 'POST',
- showLoading: true,
- }
- request(showEquityListApi, options).then((res) => {
- const data = stringToJson(res.bizContent);
- state.list = [...state.list, ...stringToJson(res.bizContent).data]
- console.log("购买2", data.data, state.list.length > 0)
- })
- }
- onReachBottom(() => {
- console.log("触底了", state.list.length, state.pageNo * 10)
- if (state.list.length < state.pageNo * 10) return state.flags = true
- console.log("触底了")
- state.pageNo++
- showEquityListRequest()
- })
- const goQuanyi = (item) => {
- navTo(`/subpackage/after-sale/add-equity/equity-product-evaluation?equityId=${item.equityId}&id=${item.id}&orderId=${item.orderId}`)
- }
- // 权益支付下单
- const equityPaymentOrderRequest = (id) => {
- state.id = id
- uni.login({
- provider: "weixin",
- success: function (e) {
- const options1 = {
- type: 2,
- data: {
- "jsCode": e.code
- },
- method: "POST",
- showLoading: true,
- };
- request(getOpenidApi, options1).then((res) => {
- const result = stringToJson(res.bizContent);
- const openidData = stringToJson(result.data);
- const options = {
- type: 2,
- data: {
- id: state.id,
- payType: "EQUITY",
- wxOpenid: openidData.openid,
- },
- method: 'POST',
- showLoading: true,
- }
- request(equityPaymentOrderApi, options).then((res) => {
- const data = stringToJson(res.bizContent);
- console.log("权益支付下单", data)
- 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("支付成功", res);
- equityPaymentTestRequest().then((item : any) => {
- msg("权益产品购买成功")
- state.pageNo = 1
- state.list = []
- showEquityListRequest()
- })
- },
- fail: function (err) {
- confirm(err, () => { }, "支付失败", false);
- },
- })
-
- })
- })
- },
- })
-
- }
- // 权益支付检测
- const equityPaymentTestRequest = () => {
- const options = {
- type: 2,
- data: {
- id: state.id,
- },
- method: 'POST',
- showLoading: true,
- }
- return new Promise(async (resolve, reject) => {
- const res = await request(equityPaymentTestApi, options);
- const data = stringToJson(res.bizContent);
- resolve(data);
- }).catch((error) => {
- reject(error);
- });
-
- }
- </script>
-
- <style>
- page {
- width: 100%;
- height: 100%;
- background-color: #EEF7F7;
- }
- </style>
- <style lang="scss" scoped>
- .selectCar-box {
- padding: 30rpx;
-
- .item {
- padding: 20rpx;
- align-items: center;
- font-size: 30rpx;
- background: #FFFFFF;
- box-shadow: 0rpx 2rpx 6rpx 0rpx rgba(223, 223, 223, 0.8);
- border-radius: 20rpx;
- margin-bottom: 30rpx;
-
- .iten-left {
- align-items: center;
- font-size: 30rpx;
-
- text {
- margin-left: 20rpx;
- font-size: 32rpx;
- font-family: Noto Sans S Chinese;
- font-weight: 400;
- color: #333333;
- }
- }
-
- .choose-item {
- width: 44rpx;
- height: 44rpx;
- background: #FFFFFF;
- border: 2rpx solid #00B38B;
- border-radius: 50%;
- margin-right: 20rpx;
- display: flex;
- justify-content: center;
- align-items: center;
- box-sizing: content-box;
- }
-
- .active {
- width: 34rpx;
- height: 34rpx;
- background: #00B38B;
- border-radius: 50%;
- }
- }
- }
-
- .btn-primary {
- border: 1px solid #00b38b;
- color: #00b38b;
- }
-
- .btn {
- height: 50rpx;
- line-height: 50rpx;
- border-radius: 30rpx;
- padding: 0 24rpx;
- font-size: 23rpx;
- box-sizing: border-box;
- margin-right: 12rpx;
- }
- </style>
|