This commit is contained in:
2023-08-18 17:22:11 +08:00
parent 1263c372cb
commit 61f840059b
36 changed files with 2371 additions and 1109 deletions

View File

@@ -3,7 +3,8 @@
<view class="text">
<view>授权提醒</view>
<view style="margin-top: 10px"
>请授权头像信息以便为您提供更好的服务</view
>请授权头像信息以便为您提供更好的服务
</view
>
<view class="bom">
<view class="btn b" @click="onCancel">随便逛逛</view>
@@ -15,45 +16,53 @@
<script setup lang="ts">
// import { computed, ref } from "vue";
import Taro from "@tarojs/taro";
import { login } from "../api/user";
import Taro from '@tarojs/taro'
import {login} from '@/api/user'
defineProps({
visible: {
type: Boolean,
default: false,
},
});
default: false
}
})
const emit = defineEmits(["update:visible", "update:info"]);
const emit = defineEmits(['update:visible', 'ok'])
const onCancel = () => {
emit("update:visible", false);
};
emit('update:visible', false)
}
const onOk = () => {
Taro.getUserProfile({
desc: "用于完善会员资料",
desc: '完善用户资料',
success: async (user) => {
console.log(user);
Taro.login({
success: async ({ code }) => {
const { data }: any = await login({
code: code,
});
Taro.setStorageSync("token", data.token);
emit("update:visible", false);
success: async ({code}) => {
try {
const {data}: any = await login({
code: code,
nickName: user.userInfo.nickName,
avatarUrl: user.userInfo.avatarUrl
})
Taro.setStorageSync('token', data.token)
emit('ok', false)
} catch (error) {
Taro.showToast({
title: error.message,
icon: 'none'
})
}
},
fail: (err) => {
console.log(err);
},
});
console.log(err)
}
})
},
fail: (err) => {
console.log(err);
},
});
};
console.log(err)
}
})
}
</script>
<style lang="scss">
@@ -71,6 +80,7 @@ const onOk = () => {
justify-content: space-evenly;
align-items: center;
margin-top: 20px;
.btn {
width: 150px;
padding: 10px;

View File

@@ -1,124 +1,134 @@
<template>
<nut-popup
position="bottom"
closeable
round
safe-area-inset-bottom
:close-on-click-overlay="false"
:style="{ height: 'auto' }"
v-model:visible="isShowPay"
@click-close-icon="closePay"
>
<view class="div">
<view style="text-align: center">支付方式</view>
<nut-cell-group>
<nut-cell
v-if="payType === 'wx'"
title="微信支付"
desc="使用微信快捷支付"
is-link
@click="goPay()"
>
<template v-slot:icon>
<IconFont
size="30"
name="https://img11.360buyimg.com/imagetools/jfs/t1/137646/13/7132/1648/5f4c748bE43da8ddd/a3f06d51dcae7b60.png"
/>
</template>
</nut-cell>
<nut-cell
v-if="payType === 'jf'"
title="积分支付"
desc="剩余积分:18888"
is-link
@click="goPay()"
>
<template v-slot:icon>
<IconFont
size="30"
name="https://img11.360buyimg.com/imagetools/jfs/t1/137646/13/7132/1648/5f4c748bE43da8ddd/a3f06d51dcae7b60.png"
/>
</template>
</nut-cell>
</nut-cell-group>
</view>
</nut-popup>
<nut-popup
position="bottom"
closeable
round
safe-area-inset-bottom
:close-on-click-overlay="false"
:style="{ height: 'auto' }"
v-model:visible="isShowPay"
@click-close-icon="closePay"
>
<view class="div">
<view style="text-align: center">支付方式</view>
<nut-cell-group>
<nut-cell
v-if="payType === 'wx'"
title="微信支付"
desc="使用微信快捷支付"
is-link
@click="goPay()"
>
<template v-slot:icon>
<IconFont
size="30"
name="https://img11.360buyimg.com/imagetools/jfs/t1/137646/13/7132/1648/5f4c748bE43da8ddd/a3f06d51dcae7b60.png"
/>
</template>
</nut-cell>
<nut-cell
v-if="payType === 'jf'"
title="积分支付"
desc="剩余积分:18888"
is-link
@click="goPay()"
>
<template v-slot:icon>
<IconFont
size="30"
name="https://img11.360buyimg.com/imagetools/jfs/t1/137646/13/7132/1648/5f4c748bE43da8ddd/a3f06d51dcae7b60.png"
/>
</template>
</nut-cell>
</nut-cell-group>
</view>
</nut-popup>
</template>
<script setup lang="ts">
import {IconFont} from "@nutui/icons-vue-taro";
import Taro from "@tarojs/taro";
import {payOrder} from "../api/user";
import {IconFont} from '@nutui/icons-vue-taro'
import Taro from '@tarojs/taro'
import {payOrder} from '@/api/order'
import {payJfOrder} from '@/api/goods'
const prop = defineProps({
isShowPay: {
required: true,
type: Boolean,
default: false,
},
payType: {
required: true,
type: String,
default: "wx",
},
});
isShowPay: {
required: true,
type: Boolean,
default: false
},
payType: {
required: true,
type: String,
default: 'wx'
},
jfInfo: {
type: Object,
default: () => {
return {}
}
}
})
const emit = defineEmits(["errPay", "closePay"]);
const emit = defineEmits(['closePay'])
const goPay = async () => {
if (prop.payType === "wx") {
const {data} = await payOrder({gid: 1, token: Taro.getStorageSync("token")});
console.log(data);
// Taro.request({
// url: "http://192.168.2.3:9000/app/order/place",
// method: "POST",
// data: {
// gid: 1,
// token: Taro.getStorageSync("token"),
// },
// success: function ({data}) {
// console.log(data);
// Taro.requestPayment({
// timeStamp: data.data.data.timeStamp,
// nonceStr: data.data.data.nonceStr,
// package: data.data.data.package,
// signType: "MD5",
// paySign: data.data.data.paySign,
// success: function (res) {
// console.log(res);
// },
// fail: function (res) {
// console.log("1111", res);
// emit("errPay", false);
// },
// });
// },
// fail: function (res) {
// console.log("1111", res);
// emit("errPay", false);
// },
// });
if (prop.payType === 'wx') {
try {
const {data} = await payOrder({gid: 1, token: Taro.getStorageSync('token')})
Taro.requestPayment({
timeStamp: data.data.timeStamp,
nonceStr: data.data.nonceStr,
package: data.data.package,
signType: data.data.signType,
paySign: data.data.paySign,
success: function (res) {
console.log(res)
},
fail: function (res) {
console.log(res)
}
})
} catch (e) {
Taro.showToast({
title: e.msg,
icon: 'none'
})
}
};
} else {
if (!prop.jfInfo) return Taro.showToast({
title: '未获取到订单信息',
icon: 'none'
})
console.log(prop.jfInfo)
const res = await payJfOrder(prop.jfInfo)
Taro.showToast({
title: res.msg,
icon: 'success',
duration: 2000
})
}
emit('closePay', false)
}
const closePay = () => {
emit("closePay", false);
};
emit('closePay', false)
}
</script>
<style lang="scss">
.nut-popup {
.nut-popup__container {
border-radius: 10px;
}
.nut-popup__container {
border-radius: 10px;
}
}
.div {
padding: 20px;
// text-align: center;
padding: 20px;
// text-align: center;
.nut-cell {
align-items: center;
}
.nut-cell {
align-items: center;
}
}
</style>