six_uniapp_0001
This commit is contained in:
@@ -0,0 +1,332 @@
|
||||
<style lang="scss" scoped>
|
||||
.root-com {
|
||||
// 功能区样式
|
||||
width: 750rpx;
|
||||
box-sizing: border-box;
|
||||
|
||||
.function-section {
|
||||
//background: #1a1a1a;
|
||||
border-radius: 24rpx;
|
||||
margin: 0 32rpx 32rpx;
|
||||
padding: 32rpx;
|
||||
box-shadow: 0 3px 1px -2px rgb(0 0 0 / 20%), 0 2px 2px 0 rgb(0 0 0 / 14%), 0 1px 5px 0 rgb(0 0 0 / 12%);
|
||||
|
||||
}
|
||||
|
||||
.section-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
.section-title-left {
|
||||
width: 10rpx;
|
||||
height: 36rpx;
|
||||
border-radius: 5rpx;
|
||||
background-color: #ef8a01;
|
||||
}
|
||||
|
||||
.title-text {
|
||||
font-size: 36rpx;
|
||||
font-weight: 600;
|
||||
//color: #fff;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.function-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
gap: 40rpx;
|
||||
justify-content: center;
|
||||
justify-items: center;
|
||||
align-items: center;
|
||||
align-content: center;
|
||||
|
||||
.function-item {
|
||||
width: 90%;
|
||||
|
||||
//cursor: pointer;
|
||||
|
||||
.function-item-i {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
|
||||
.item-icon {
|
||||
width: 80rpx;
|
||||
height: 80rpx;
|
||||
border-radius: 20rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-bottom: 16rpx;
|
||||
border: 2rpx solid #444;
|
||||
}
|
||||
|
||||
.icon-text {
|
||||
font-size: 36rpx;
|
||||
}
|
||||
|
||||
.item-title {
|
||||
font-size: 24rpx;
|
||||
//color: #ccc;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
</style>
|
||||
<template>
|
||||
<view class="root-com">
|
||||
<view class="function-section">
|
||||
<view class="section-title">
|
||||
<view class="section-title-left"></view>
|
||||
<view class="line-widht-number" style="width: 8rpx"></view>
|
||||
<view class="title-text">我的服务</view>
|
||||
</view>
|
||||
<wd-divider></wd-divider>
|
||||
<view class="function-grid">
|
||||
<view v-for="item in functionList" :key="item.id" class="function-item"
|
||||
@click="点击各项的服务(item)">
|
||||
<view class="function-item-i" v-if="item.is_show">
|
||||
<view class="item-icon">
|
||||
<text class="icon-text">{{ item.icon }}</text>
|
||||
</view>
|
||||
<text class="item-title">{{ item.title }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<wd-divider></wd-divider>
|
||||
</view>
|
||||
</view>
|
||||
<wd-toast selector="default-toast"/>
|
||||
<wd-message-box selector="default-message-box"/>
|
||||
</template>
|
||||
|
||||
|
||||
<script lang="ts" setup>
|
||||
import {watchEffect, ref} from "vue";
|
||||
import {useMessage, useToast} from "wot-design-uni";
|
||||
import {useRequest} from "@uni-helper/uni-use";
|
||||
import {用工关系_更新用工关系绑定关系数据, 用工关系_用户提交绑定成功后更新数据} from "@/hooks/接口API";
|
||||
import {useMainXiaoStore} from "@/stores/piniaPro/miniChatStore";
|
||||
import type {miniUserInfo} from "@/hooks/mini用户类型";
|
||||
import {get获取用户当前位置信息} from "@/hooks/获取用户定位信息";
|
||||
|
||||
defineOptions({options: {styleIsolation: "shared"}, name: "me-com-user-server"});
|
||||
|
||||
let toast = useToast("default-toast");
|
||||
let message = useMessage("default-message-box");
|
||||
let xiaoMain = useMainXiaoStore();
|
||||
const getUser用户位置 = new get获取用户当前位置信息(<string>xiaoMain.mini_openid, <string>xiaoMain.mini_unionid);
|
||||
|
||||
interface FunctionItem {
|
||||
id: number;
|
||||
title: "订单查询" | "我的收藏" | "收件地址" | "我的卡券" | "积分管理" | "投诉建议" | "同城服务" | "订阅消息" | "加入我们";
|
||||
icon: string;
|
||||
path?: string;
|
||||
is_show: boolean;
|
||||
}
|
||||
|
||||
async function 发起订阅消息事件(): Promise<void> {
|
||||
try {
|
||||
let tempId = "RvGf7wyALX4djhBgeIp6jqlfAKNzd_weXRFEd1P54fk";
|
||||
let requestSubscribeMessageSuccessCallbackResult = await wx.requestSubscribeMessage({tmplIds: ["RvGf7wyALX4djhBgeIp6jqlfAKNzd_weXRFEd1P54fk"]});
|
||||
|
||||
if (requestSubscribeMessageSuccessCallbackResult[tempId] === "accept") {
|
||||
// 允许后的操作
|
||||
toast.success({msg: "订阅成功", position: "middle"});
|
||||
// 订阅成功后 的操作,需要往后台发送请求,来记录用户操作成功了次数
|
||||
// let apiData = await instance.post<ApiAxiosResponse<Array<string>>>("/submsg/add_messages/", {
|
||||
// self_mini_openid: xiaoMain.mini_openid, self_mini_unionid: xiaoMain.mini_unionid,
|
||||
// });
|
||||
}
|
||||
if (requestSubscribeMessageSuccessCallbackResult[tempId] === "reject") {
|
||||
// 拒绝后的结果
|
||||
// 引导用户再打开设置
|
||||
let messages = await message.confirm({msg: "可以即时获得积分开团中奖信息", title: "订阅消息授权"});
|
||||
console.log(messages.action);
|
||||
if (messages.action === "confirm") {
|
||||
console.log("点击了确认");
|
||||
let openSettingSuccessCallbackResult = await wx.openSetting({withSubscriptions: true});
|
||||
console.log(openSettingSuccessCallbackResult, "🍎 🍏 🍊 🍎 🍏 🍊 🍎 🍏 🍊 🍎 🍏 🍊 🍎 🍏 ");
|
||||
if (openSettingSuccessCallbackResult.subscriptionsSetting.itemSettings?.[tempId] === "accept") {
|
||||
// 发起订阅事件,一定要是点击的事件,这样调用是不起作用的
|
||||
// let messageResult = await message.alert( { msg: "确认订阅", title: "授权成功" } );
|
||||
// if ( messageResult.action === "confirm" ) {
|
||||
// let requestSubscribeMessageSuccessCallbackResult = await wx.requestSubscribeMessage( { tmplIds: [ "RvGf7wyALX4djhBgeIp6jqlfAKNzd_weXRFEd1P54fk" ] } );
|
||||
// console.log( "🍎 🍏 🍊 🍎 🍏 🍊 🍎 🍏 🍊 🍎 🍏 🍊 🍎 🍏 ", requestSubscribeMessageSuccessCallbackResult );
|
||||
// }
|
||||
//
|
||||
}
|
||||
if (openSettingSuccessCallbackResult.subscriptionsSetting.itemSettings?.[tempId] === "reject") {
|
||||
toast.error({msg: "授权已拒绝", position: "middle"});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
let getSettingSuccessCallbackResult = await wx.getSetting({withSubscriptions: true});
|
||||
if (getSettingSuccessCallbackResult.subscriptionsSetting.mainSwitch) {
|
||||
// 如里这里为真则表示用户是打开了订阅配置的
|
||||
console.log("🍎 🍏 🍊 🍎 🍏 🍊 🍎 🍏 🍊 🍎 🍏 🍊 🍎 🍏总开关是打开的 ");
|
||||
}
|
||||
if (!getSettingSuccessCallbackResult.subscriptionsSetting.mainSwitch) {
|
||||
// 在这里需要用户打开设置页面
|
||||
let messages = await message.confirm({msg: "可以即时获得积分开团中奖信息", title: "订阅消息授权"});
|
||||
if (messages.action === "confirm") {
|
||||
console.log("点击了确认");
|
||||
let openSettingSuccessCallbackResult = await wx.openSetting({withSubscriptions: true});
|
||||
console.log(openSettingSuccessCallbackResult.subscriptionsSetting, "🍎 🍏 🍊 🍎 🍏 🍊 🍎 🍏 🍊 🍎 🍏 🍊 🍎 🍏 为什么啊");
|
||||
let getSettingSuccessCallbackResult = await wx.getSetting({withSubscriptions: true});
|
||||
console.log(getSettingSuccessCallbackResult, "🍎 🍏 🍊 🍎 🍏 🍊 🍎 🍏 🍊 🍎 🍏 🍊 🍎 🍏 ");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const functionList = ref<FunctionItem[]>([
|
||||
{id: 1, title: "订单查询", icon: "📦", is_show: true},
|
||||
{id: 6, title: "积分管理", icon: "💰", is_show: true},
|
||||
{id: 3, title: "收件地址", icon: "📍", is_show: true},
|
||||
{id: 7, title: "投诉建议", icon: "💬", is_show: true},
|
||||
{id: 5, title: "加入我们", icon: "🤝", is_show: true},
|
||||
{id: 2, title: "同城服务", icon: "🏛️", is_show: true},
|
||||
{id: 4, title: "订阅消息", icon: "📪", is_show: false},
|
||||
]);
|
||||
// 监听绑定状态变化,动态更新“加入我们”的显示
|
||||
watchEffect(() => {
|
||||
|
||||
for (let item of functionList.value) {
|
||||
if (item.title === "同城服务") {
|
||||
if (xiaoMain.mini_user_data?.user_区县) {
|
||||
item.is_show = false;
|
||||
}
|
||||
}
|
||||
if (item.title === "加入我们") {
|
||||
if (xiaoMain.mini_user_data?.user_绑定用工关系 === "用工关系已绑定") {
|
||||
item.is_show = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
async function 点击各项的服务(item: FunctionItem): Promise<void> {
|
||||
//
|
||||
if (item.title === "收件地址") {
|
||||
// 进入我的地址页面
|
||||
await wx.vibrateShort({type: "heavy"});
|
||||
uni.navigateTo({url: "/subPackages/homeSubPages/用户配送地址页面/用户配送地址页面"}).then().catch(() => wx.reLaunch({url: "/pageTabBar/Home/Home"}));
|
||||
}
|
||||
if (item.title === "订单查询") {
|
||||
await wx.vibrateShort({type: "heavy"});
|
||||
uni.navigateTo({url: "/subPackages/homeSubPages/订单数据页面/订单数据页面"}).then(() => {
|
||||
}).catch(() => wx.reLaunch({url: "/pageTabBar/Home/Home"}));
|
||||
}
|
||||
if (item.title === "投诉建议") {
|
||||
await wx.vibrateShort({type: "heavy"});
|
||||
wx.openCustomerServiceChat({
|
||||
// 连接的 (投诉建议客服)
|
||||
extInfo: {url: "https://work.weixin.qq.com/kfid/kfc1a1611bf703deccf"}, corpId: "wwbe6369dc26a9d83a",
|
||||
success: (res) => {
|
||||
|
||||
},
|
||||
fail: (res) => {
|
||||
console.log(res);
|
||||
},
|
||||
},
|
||||
);
|
||||
}
|
||||
if (item.title === "加入我们") {
|
||||
await wx.vibrateShort({type: "heavy"});
|
||||
wx.checkEmployeeRelation({
|
||||
success(res) {
|
||||
console.log("绑定状态:", res.bindingStatus);
|
||||
if (res.bindingStatus === "accept") {
|
||||
console.log("这里表示已经绑定成功了");
|
||||
useRequest(用工关系_更新用工关系绑定关系数据, {
|
||||
method: "POST", data: {
|
||||
self_mini_openid: xiaoMain.mini_openid, self_mini_unionid: xiaoMain.mini_unionid,
|
||||
}
|
||||
}).then((data) => {
|
||||
console.log(data);
|
||||
xiaoMain.mini_user_data = data.data.value;
|
||||
});
|
||||
}
|
||||
if (res.bindingStatus === "reject") {
|
||||
wx.showModal({
|
||||
title: "温馨提示",
|
||||
content: "您之前拒绝了员工绑定,重新绑定需要联系客服",
|
||||
confirmText: "重新绑定",
|
||||
cancelText: "暂不绑定",
|
||||
success(modalRes) {
|
||||
console.log(modalRes);
|
||||
if (modalRes.confirm) {
|
||||
// 重新调绑定(必须在用户点击事件里)
|
||||
wx.bindEmployeeRelation({
|
||||
tmplIds: ["SFFgGF1bN56_KNd_4HicCFBBfu2PCRwCyQ5upr-EVk9Vdyl4wyyQ7B1mJvjceR29"],
|
||||
success: (res) => {
|
||||
console.log(res.errMsg);
|
||||
console.log("🍎 🍏 🍎 🍏 🍎 🍏 🍎 🍏 ", res);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (modalRes.cancel) {
|
||||
console.log("🍎 🍏 🍎 🍏 🍎 🍏 🍎 🍏 用户拒绝了 ", modalRes.cancel);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
if (res.bindingStatus === "") {
|
||||
// 这里表示用户,未绑定且未拒绝
|
||||
console.log("🍎 🍏 🍎 🍏 🍎 🍏 🍎 🍏 当前的状态 这里表示用户,未绑定且未拒绝 ",);
|
||||
wx.bindEmployeeRelation({
|
||||
tmplIds: ["SFFgGF1bN56_KNd_4HicCFBBfu2PCRwCyQ5upr-EVk9Vdyl4wyyQ7B1mJvjceR29"],
|
||||
success: (res) => {
|
||||
console.log(res.errMsg);
|
||||
console.log("🍎 🍏 🍎 🍏 🍎 🍏 🍎 🍏", res);
|
||||
useRequest<miniUserInfo>(用工关系_用户提交绑定成功后更新数据, {
|
||||
method: "POST", data: {
|
||||
self_mini_openid: xiaoMain.mini_openid,
|
||||
self_mini_unionid: xiaoMain.mini_unionid,
|
||||
}
|
||||
}).then(res => {
|
||||
xiaoMain.mini_user_data = res.data.value;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
},
|
||||
fail: (res) => {
|
||||
console.log("捕获错误❌❌❌❌❌❌", res);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
if (item.title === "订阅消息") {
|
||||
await wx.vibrateShort({type: "heavy"});//medium heavy light
|
||||
|
||||
}
|
||||
if (item.title === "同城服务") {
|
||||
await wx.vibrateShort({type: "heavy"});
|
||||
// 在这里提醒用户发起位置授权
|
||||
await getUser用户位置.getUserLocation();
|
||||
|
||||
}
|
||||
if (item.title === "积分管理") {
|
||||
await wx.vibrateShort({type: "heavy"});
|
||||
uni.navigateTo({url: "/subPackages/homeSubPages/用户积分页面/用户积分页面"}).then().catch(() => wx.reLaunch({url: "/pageTabBar/Home/Home"}));
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user