feat: 抖音小程序开发
This commit is contained in:
@@ -13,7 +13,25 @@
|
|||||||
"ipLargeImageStep": 147,
|
"ipLargeImageStep": 147,
|
||||||
"ipSmallImageStep": 117,
|
"ipSmallImageStep": 117,
|
||||||
"ipLargeTime": 4,
|
"ipLargeTime": 4,
|
||||||
"ipSmallTime": 4
|
"ipSmallTime": 4,
|
||||||
|
"grantType": "wechat"
|
||||||
|
},
|
||||||
|
"zhinianDY": {
|
||||||
|
"clientId": "7",
|
||||||
|
"appId": "wx5e79df5996572539",
|
||||||
|
"name": "智念",
|
||||||
|
"placeholder": "快告诉智念您在想什么~",
|
||||||
|
"loginDesc": "您好,欢迎来到智念科技",
|
||||||
|
"logo": "https://oss.nianxx.cn/mp/static/version_101/login/dh_logo.png",
|
||||||
|
"ipLargeImage": "https://oss.nianxx.cn/mp/static/version_101/dh/dh_large.png",
|
||||||
|
"ipSmallImage": "https://oss.nianxx.cn/mp/static/version_101/dh/dh_small.png",
|
||||||
|
"ipLargeImageHeight": 19687,
|
||||||
|
"ipSmallImageHeight": 3744,
|
||||||
|
"ipLargeImageStep": 147,
|
||||||
|
"ipSmallImageStep": 117,
|
||||||
|
"ipLargeTime": 4,
|
||||||
|
"ipSmallTime": 4,
|
||||||
|
"grantType": "douyin"
|
||||||
},
|
},
|
||||||
"duohua": {
|
"duohua": {
|
||||||
"clientId": "2",
|
"clientId": "2",
|
||||||
@@ -29,7 +47,8 @@
|
|||||||
"ipLargeImageStep": 147,
|
"ipLargeImageStep": 147,
|
||||||
"ipSmallImageStep": 117,
|
"ipSmallImageStep": 117,
|
||||||
"ipLargeTime": 4,
|
"ipLargeTime": 4,
|
||||||
"ipSmallTime": 4
|
"ipSmallTime": 4,
|
||||||
|
"grantType": "wechat"
|
||||||
},
|
},
|
||||||
"tianmu": {
|
"tianmu": {
|
||||||
"clientId": "4",
|
"clientId": "4",
|
||||||
@@ -45,6 +64,24 @@
|
|||||||
"ipLargeImageStep": 71,
|
"ipLargeImageStep": 71,
|
||||||
"ipSmallImageStep": 148,
|
"ipSmallImageStep": 148,
|
||||||
"ipLargeTime": 4,
|
"ipLargeTime": 4,
|
||||||
"ipSmallTime": 6
|
"ipSmallTime": 6,
|
||||||
|
"grantType": "wechat"
|
||||||
|
},
|
||||||
|
"tianmuDY": {
|
||||||
|
"clientId": "7",
|
||||||
|
"appId": "wx0be424e1d22065a9",
|
||||||
|
"name": "沐沐",
|
||||||
|
"placeholder": "快告诉沐沐您在想什么~",
|
||||||
|
"loginDesc": "您好,欢迎来到天沐温泉",
|
||||||
|
"logo": "https://oss.nianxx.cn/mp/static/version_101/login/tm_logo.png",
|
||||||
|
"ipLargeImage": "https://oss.nianxx.cn/mp/static/version_101/tm/tm_large.png",
|
||||||
|
"ipSmallImage": "https://oss.nianxx.cn/mp/static/version_101/tm/tm_small.png",
|
||||||
|
"ipLargeImageHeight": 9514,
|
||||||
|
"ipSmallImageHeight": 4736,
|
||||||
|
"ipLargeImageStep": 71,
|
||||||
|
"ipSmallImageStep": 148,
|
||||||
|
"ipLargeTime": 4,
|
||||||
|
"ipSmallTime": 6,
|
||||||
|
"grantType": "douyin"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"appid": "wx0be424e1d22065a9",
|
"appid": "wx5e79df5996572539",
|
||||||
"compileType": "miniprogram",
|
"compileType": "miniprogram",
|
||||||
"libVersion": "3.8.10",
|
"libVersion": "3.8.10",
|
||||||
"packOptions": {
|
"packOptions": {
|
||||||
|
|||||||
@@ -67,7 +67,12 @@ const swipering = ref(false);
|
|||||||
const animatingOut = ref(false);
|
const animatingOut = ref(false);
|
||||||
let reorderTimer = null;
|
let reorderTimer = null;
|
||||||
|
|
||||||
|
// #ifdef MP-TOUTIAO
|
||||||
|
const { windowWidth } = tt.getSystemInfoSync();
|
||||||
|
// #endif
|
||||||
|
// #ifdef MP-WEIXIN
|
||||||
const { windowWidth } = uni.getWindowInfo();
|
const { windowWidth } = uni.getWindowInfo();
|
||||||
|
// #endif
|
||||||
|
|
||||||
let uidCounter = 0;
|
let uidCounter = 0;
|
||||||
// 始终生成全局唯一的 __uid,避免因重复 key 导致后续卡片无法正确重渲染与绑定事件
|
// 始终生成全局唯一的 __uid,避免因重复 key 导致后续卡片无法正确重渲染与绑定事件
|
||||||
|
|||||||
@@ -1,37 +1,23 @@
|
|||||||
<template>
|
<template>
|
||||||
<view :class="navBarClass" :style="navBarStyle">
|
<view :class="navBarClass" :style="navBarStyle">
|
||||||
<!-- 状态栏占位 -->
|
<!-- 状态栏占位 -->
|
||||||
<view
|
<view :style="{ height: statusBarHeight + 'px' }" v-if="!hideStatusBar"></view>
|
||||||
:style="{ height: statusBarHeight + 'px' }"
|
|
||||||
v-if="!hideStatusBar"
|
|
||||||
></view>
|
|
||||||
|
|
||||||
<!-- 导航栏内容 -->
|
<!-- 导航栏内容 -->
|
||||||
<view
|
<view class="flex flex-items-center flex-justify-between border-box pl-8 pr-8"
|
||||||
class="flex flex-items-center flex-justify-between border-box pl-8 pr-8"
|
:style="{ height: navBarHeight + 'px' }">
|
||||||
:style="{ height: navBarHeight + 'px' }"
|
|
||||||
>
|
|
||||||
<!-- 左侧返回按钮 -->
|
<!-- 左侧返回按钮 -->
|
||||||
<view
|
<view class="nav-bar-left flex flex-items-center flex-justify-center" v-if="showBack" @click="handleBack">
|
||||||
class="nav-bar-left flex flex-items-center flex-justify-center"
|
|
||||||
v-if="showBack"
|
|
||||||
@click="handleBack"
|
|
||||||
>
|
|
||||||
<uni-icons type="left" size="20" :color="backIconColor" />
|
<uni-icons type="left" size="20" :color="backIconColor" />
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 中间标题区域 -->
|
<!-- 中间标题区域 -->
|
||||||
<view
|
<view :class="[
|
||||||
:class="[
|
|
||||||
'nav-bar-center flex flex-items-center flex-justify-center',
|
'nav-bar-center flex flex-items-center flex-justify-center',
|
||||||
`nav-bar-center--${titleAlign}`,
|
`nav-bar-center--${titleAlign}`,
|
||||||
]"
|
]">
|
||||||
>
|
|
||||||
<slot name="title">
|
<slot name="title">
|
||||||
<text
|
<text class="font-size-17 font-500 color-000" :style="{ color: titleColor }">
|
||||||
class="font-size-17 font-500 color-000"
|
|
||||||
:style="{ color: titleColor }"
|
|
||||||
>
|
|
||||||
{{ title }}
|
{{ title }}
|
||||||
</text>
|
</text>
|
||||||
</slot>
|
</slot>
|
||||||
@@ -107,7 +93,13 @@ const navBarHeight = ref(44); // 默认导航栏高度
|
|||||||
|
|
||||||
// 获取系统信息
|
// 获取系统信息
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
const systemInfo = uni.getSystemInfoSync();
|
// #ifdef MP-TOUTIAO
|
||||||
|
const systemInfo = tt.getSystemInfoSync();
|
||||||
|
// #endif
|
||||||
|
// #ifdef MP-WEIXIN
|
||||||
|
const systemInfo = uni.getWindowInfo();
|
||||||
|
// #endif
|
||||||
|
|
||||||
statusBarHeight.value = systemInfo.statusBarHeight || 0;
|
statusBarHeight.value = systemInfo.statusBarHeight || 0;
|
||||||
|
|
||||||
// 根据平台设置导航栏高度
|
// 根据平台设置导航栏高度
|
||||||
|
|||||||
@@ -12,8 +12,9 @@ import rawConfigs from '../../client-configs.json' with { type: 'json' };
|
|||||||
export const CLIENT_CONFIGS = rawConfigs;
|
export const CLIENT_CONFIGS = rawConfigs;
|
||||||
|
|
||||||
// 获取当前用户端配置
|
// 获取当前用户端配置
|
||||||
export const getCurrentConfig = () => CLIENT_CONFIGS.tianmu;
|
export const getCurrentConfig = () => CLIENT_CONFIGS.zhinianDY;
|
||||||
export const clientId = getCurrentConfig().clientId;
|
export const clientId = getCurrentConfig().clientId;
|
||||||
|
export const grantType = getCurrentConfig().grantType;
|
||||||
export const appId = getCurrentConfig().appId;
|
export const appId = getCurrentConfig().appId;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { oauthToken, checkUserPhone } from "@/request/api/LoginApi";
|
import { oauthToken, checkUserPhone } from "@/request/api/LoginApi";
|
||||||
import { loginAuth, bindPhone } from "@/manager/LoginManager";
|
import { loginAuth, bindPhone } from "@/manager/LoginManager";
|
||||||
import { clientId } from "@/constant/base";
|
import { clientId, grantType } from "@/constant/base";
|
||||||
import { getAccessToken, removeAccessToken, setAccessToken } from "../constant/token";
|
import { getAccessToken, removeAccessToken, setAccessToken } from "../constant/token";
|
||||||
import { NOTICE_EVENT_LOGIN_SUCCESS } from "@/constant/constant";
|
import { NOTICE_EVENT_LOGIN_SUCCESS } from "@/constant/constant";
|
||||||
|
|
||||||
@@ -70,13 +70,19 @@ export const checkToken = () => {
|
|||||||
// 刷新token
|
// 刷新token
|
||||||
export const refreshToken = () => {
|
export const refreshToken = () => {
|
||||||
return new Promise(async (resolve) => {
|
return new Promise(async (resolve) => {
|
||||||
|
uni.getProvider({
|
||||||
|
service: 'oauth',
|
||||||
|
success: function (res) {
|
||||||
|
// 获取客户端类型
|
||||||
|
console.log('获取客户端类型:', res.provider)
|
||||||
uni.login({
|
uni.login({
|
||||||
provider: "weixin", //使用微信登录
|
provider: res.provider, //使用微信登录
|
||||||
success: async ({ code }) => {
|
success: async ({ code }) => {
|
||||||
console.log("进入 refreshToken success", code);
|
console.log("进入 refreshToken success code:", code);
|
||||||
|
// console.log("进入 refreshToken success anonymousCode:", anonymousCode);
|
||||||
const params = {
|
const params = {
|
||||||
openIdCode: [code],
|
openIdCode: [code],
|
||||||
grant_type: "wechat",
|
grant_type: grantType,
|
||||||
scope: "server",
|
scope: "server",
|
||||||
clientId: clientId,
|
clientId: clientId,
|
||||||
};
|
};
|
||||||
@@ -100,5 +106,7 @@ export const refreshToken = () => {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -60,7 +60,7 @@
|
|||||||
朵花:wx23f86d809ae80259
|
朵花:wx23f86d809ae80259
|
||||||
*/
|
*/
|
||||||
"mp-weixin": {
|
"mp-weixin": {
|
||||||
"appid": "wx0be424e1d22065a9",
|
"appid": "wx5e79df5996572539",
|
||||||
"setting": {
|
"setting": {
|
||||||
"urlCheck": false,
|
"urlCheck": false,
|
||||||
"minified": true
|
"minified": true
|
||||||
|
|||||||
@@ -16,10 +16,12 @@
|
|||||||
<text class="amt font-size-18 font-500 font-family-misans-vf line-height-24 color-FF3D60 mr-4">
|
<text class="amt font-size-18 font-500 font-family-misans-vf line-height-24 color-FF3D60 mr-4">
|
||||||
{{ item.specificationPrice }}
|
{{ item.specificationPrice }}
|
||||||
</text>
|
</text>
|
||||||
|
<!-- #ifdef MP-WEIXIN -->
|
||||||
<text class="font-size-12 line-height-16 color-99A0AE">
|
<text class="font-size-12 line-height-16 color-99A0AE">
|
||||||
/{{ item.stockUnitLabel }}
|
/{{ item.stockUnitLabel }}
|
||||||
</text>
|
</text>
|
||||||
<text class="btn border-box rounded-10 color-white ml-16" @click.stop="handleBooking(item)">订</text>
|
<text class="btn border-box rounded-10 color-white ml-16" @click.stop="handleBooking(item)">订</text>
|
||||||
|
<!-- #endif -->
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
@@ -49,7 +49,7 @@
|
|||||||
>
|
>
|
||||||
{{ calculatedTotalPrice }}
|
{{ calculatedTotalPrice }}
|
||||||
</view>
|
</view>
|
||||||
|
<!-- #ifdef MP-WEIXIN -->
|
||||||
<view
|
<view
|
||||||
class="btn border-box rounded-10 flex flex-items-center ml-auto pl-8"
|
class="btn border-box rounded-10 flex flex-items-center ml-auto pl-8"
|
||||||
@click="navigateToPay(goodsData)"
|
@click="navigateToPay(goodsData)"
|
||||||
@@ -60,8 +60,10 @@
|
|||||||
/>
|
/>
|
||||||
<text class="font-size-16 font-500 color-white">立即预定</text>
|
<text class="font-size-16 font-500 color-white">立即预定</text>
|
||||||
</view>
|
</view>
|
||||||
|
<!-- #endif -->
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
|
||||||
<!-- 日历组件 -->
|
<!-- 日历组件 -->
|
||||||
<Calender
|
<Calender
|
||||||
:visible="calendarVisible"
|
:visible="calendarVisible"
|
||||||
|
|||||||
@@ -180,6 +180,7 @@ const initRecord = () => {
|
|||||||
// 监听键盘高度变化
|
// 监听键盘高度变化
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
// 监听键盘弹起
|
// 监听键盘弹起
|
||||||
|
// #ifdef MP-WEIXIN
|
||||||
uni.onKeyboardHeightChange((res) => {
|
uni.onKeyboardHeightChange((res) => {
|
||||||
keyboardHeight.value = res.height;
|
keyboardHeight.value = res.height;
|
||||||
if (res.height) {
|
if (res.height) {
|
||||||
@@ -188,8 +189,8 @@ onMounted(() => {
|
|||||||
emit("keyboardHide");
|
emit("keyboardHide");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
initRecord();
|
initRecord();
|
||||||
|
// #endif
|
||||||
});
|
});
|
||||||
|
|
||||||
const sendMessage = () => {
|
const sendMessage = () => {
|
||||||
|
|||||||
@@ -296,11 +296,19 @@ const addNoticeListener = () => {
|
|||||||
|
|
||||||
/// =============生命周期函数↓================
|
/// =============生命周期函数↓================
|
||||||
onLoad(() => {
|
onLoad(() => {
|
||||||
uni.getSystemInfo({
|
console.log(21212121212)
|
||||||
success: (res) => {
|
nextTick(() => {
|
||||||
statusBarHeight.value = res.statusBarHeight || 20;
|
// #ifdef MP-TOUTIAO
|
||||||
},
|
const systemInfo = tt.getSystemInfoSync();
|
||||||
});
|
// #endif
|
||||||
|
// #ifdef MP-WEIXIN
|
||||||
|
const systemInfo = uni.getWindowInfo();
|
||||||
|
// #endif
|
||||||
|
|
||||||
|
statusBarHeight.value = systemInfo.statusBarHeight || 20;
|
||||||
|
console.log(1213213123, statusBarHeight.value, systemInfo.statusBarHeight)
|
||||||
|
})
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// token存在,初始化数据
|
// token存在,初始化数据
|
||||||
|
|||||||
@@ -38,8 +38,9 @@
|
|||||||
</button>
|
</button>
|
||||||
<!-- #endif -->
|
<!-- #endif -->
|
||||||
<!-- #ifdef MP-TOUTIAO -->
|
<!-- #ifdef MP-TOUTIAO -->
|
||||||
<button class="login-btn" type="primary" open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumberHandler"
|
<!-- <button class="login-btn" type="primary" open-type="getPhoneNumber" @getphonenumber="getPhoneNumberHandler"
|
||||||
bindtap="bindPhone">登录</button>
|
@bindtap="bindPhone">登录</button> -->
|
||||||
|
<button class="login-btn" type="primary" @click="loginhandle">登录</button>
|
||||||
<!-- #endif -->
|
<!-- #endif -->
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
@@ -107,9 +108,13 @@ const getPhoneNumber = (e) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const getPhoneNumberHandler = (e) => {
|
const getPhoneNumberHandler = (e) => {
|
||||||
console.log(e.detail.errMsg);
|
console.log('getphonenumber:', e)
|
||||||
console.log(e.detail.iv);
|
// console.log(e.detail.errMsg);
|
||||||
console.log(e.detail.encryptedData);
|
// console.log(e.detail.iv);
|
||||||
|
// console.log(e.detail.encryptedData);
|
||||||
|
}
|
||||||
|
const bindPhone = (e) => {
|
||||||
|
console.log('bindPhone:', e)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 抖音登录获取code
|
// 抖音登录获取code
|
||||||
@@ -188,10 +193,35 @@ getPrivacyAgreementData();
|
|||||||
|
|
||||||
// 页面显示时刷新token
|
// 页面显示时刷新token
|
||||||
onShow(async () => {
|
onShow(async () => {
|
||||||
loginDy();
|
// #ifdef MP-TOUTIAO
|
||||||
|
// loginDy();
|
||||||
|
// #endif
|
||||||
|
// #ifdef MP-WEIXIN
|
||||||
|
loginhandle();
|
||||||
|
// #endif
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
const loginhandle = async () => {
|
||||||
|
// 如果需要微信登录,直接返回
|
||||||
|
|
||||||
|
// #ifdef MP-TOUTIAO
|
||||||
|
if (!isAgree.value) {
|
||||||
|
uni.showToast({
|
||||||
|
title: "请先同意服务协议和隐私协议",
|
||||||
|
icon: "none",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// #endif
|
||||||
|
|
||||||
const res = await refreshToken();
|
const res = await refreshToken();
|
||||||
needWxAuthLogin.value = res;
|
needWxAuthLogin.value = res;
|
||||||
});
|
|
||||||
|
// #ifdef MP-TOUTIAO
|
||||||
|
loginSuccess();
|
||||||
|
// #endif
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -151,7 +151,9 @@ export default {
|
|||||||
},
|
},
|
||||||
mounted () {
|
mounted () {
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
|
if (this.root) {
|
||||||
for (this.root = this.$parent; this.root.$options.name !== 'mp-html'; this.root = this.root.$parent);
|
for (this.root = this.$parent; this.root.$options.name !== 'mp-html'; this.root = this.root.$parent);
|
||||||
|
}
|
||||||
})
|
})
|
||||||
// #ifdef H5 || APP-PLUS
|
// #ifdef H5 || APP-PLUS
|
||||||
if (this.opts[0]) {
|
if (this.opts[0]) {
|
||||||
|
|||||||
@@ -77,18 +77,31 @@ const config = {
|
|||||||
}
|
}
|
||||||
const tagSelector = {}
|
const tagSelector = {}
|
||||||
let windowWidth, system
|
let windowWidth, system
|
||||||
|
|
||||||
|
|
||||||
|
// #ifdef MP-TOUTIAO
|
||||||
|
const systemInfo = tt.getSystemInfoSync()
|
||||||
|
windowWidth = systemInfo.windowWidth
|
||||||
|
system = systemInfo.system
|
||||||
|
// #endif
|
||||||
// #ifdef MP-WEIXIN
|
// #ifdef MP-WEIXIN
|
||||||
if (uni.canIUse('getWindowInfo')) {
|
|
||||||
windowWidth = uni.getWindowInfo().windowWidth
|
windowWidth = uni.getWindowInfo().windowWidth
|
||||||
system = uni.getDeviceInfo().system
|
system = uni.getDeviceInfo().system
|
||||||
} else {
|
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
|
|
||||||
|
if (uni.canIUse('getWindowInfo')) {
|
||||||
|
// #ifdef MP-WEIXIN
|
||||||
|
windowWidth = uni.getWindowInfo().windowWidth
|
||||||
|
system = uni.getDeviceInfo().system
|
||||||
|
// #endif
|
||||||
|
} else {
|
||||||
|
// #ifdef MP-WEIXIN
|
||||||
const systemInfo = uni.getSystemInfoSync()
|
const systemInfo = uni.getSystemInfoSync()
|
||||||
windowWidth = systemInfo.windowWidth
|
windowWidth = systemInfo.windowWidth
|
||||||
// #ifdef MP-WEIXIN
|
|
||||||
system = systemInfo.system
|
system = systemInfo.system
|
||||||
}
|
|
||||||
// #endif
|
// #endif
|
||||||
|
}
|
||||||
const blankChar = makeMap(' ,\r,\n,\t,\f')
|
const blankChar = makeMap(' ,\r,\n,\t,\f')
|
||||||
let idIndex = 0
|
let idIndex = 0
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,9 @@ export default {
|
|||||||
if (allowShare) {
|
if (allowShare) {
|
||||||
uni.showShareMenu({
|
uni.showShareMenu({
|
||||||
withShareTicket: true,
|
withShareTicket: true,
|
||||||
|
// #ifdef MP-WEIXIN
|
||||||
menus: ["shareAppMessage", "shareTimeline"],
|
menus: ["shareAppMessage", "shareTimeline"],
|
||||||
|
// #endif
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user