feat: 登录联调
This commit is contained in:
parent
62446e075b
commit
d4fecd7e9b
@ -7,18 +7,18 @@ const envVersion = accountInfo.miniProgram.envVersion || "trial";
|
|||||||
|
|
||||||
const GDEnvs = {
|
const GDEnvs = {
|
||||||
develop: {
|
develop: {
|
||||||
web: "https://tlth5.yijiesudai.com/unicom",
|
web: "https://h5.goudezhao.com",
|
||||||
host: "https://api.1024api.com",
|
host: "https://api.1024api.com",
|
||||||
mdHost: "https://tcomlog.yijiesudai.com",
|
mdHost: "https://tcomlog.yijiesudai.com",
|
||||||
},
|
},
|
||||||
trial: {
|
trial: {
|
||||||
web: "https://tlth5.yijiesudai.com/unicom",
|
web: "https://h5.goudezhao.com",
|
||||||
host: "https://api.1024api.com",
|
host: "https://api.1024api.com",
|
||||||
mdHost: "https://tcomlog.yijiesudai.com",
|
mdHost: "https://tcomlog.yijiesudai.com",
|
||||||
},
|
},
|
||||||
release: {
|
release: {
|
||||||
web: "https://lth5.blingfintech.com/unicom",
|
web: "https://h5.goudezhao.com",
|
||||||
host: "https://lth5.blingfintech.com",
|
host: "https://api.1024api.com",
|
||||||
mdHost: "https://comlog.yijiesudai.com",
|
mdHost: "https://comlog.yijiesudai.com",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,56 +1,64 @@
|
|||||||
import { httpRequest } from '../../utils/request'
|
import { httpRequest } from "../../utils/request";
|
||||||
const baseUrl = require('../base').allBaseUrl.GDEnvs.host
|
const baseUrl = require("../base").allBaseUrl.GDEnvs.host;
|
||||||
|
|
||||||
// 获取图形验证码
|
// 获取图形验证码
|
||||||
export const apiGetCaptchaImage = () => {
|
export const apiGetCaptchaImage = () => {
|
||||||
return httpRequest.post<{
|
return httpRequest.post<{
|
||||||
data: {
|
data: {
|
||||||
uuid: string
|
uuid: string;
|
||||||
img: string
|
img: string;
|
||||||
}
|
};
|
||||||
}>(`${baseUrl}/lt-web/xs/xcx/common/captchaImage`, {})
|
}>(`${baseUrl}/lt-web/xs/xcx/common/captchaImage`, {});
|
||||||
}
|
};
|
||||||
|
|
||||||
// 获取短信验证码
|
// 获取短信验证码
|
||||||
export const apiSendSms = (data: {
|
export const apiSendSms = (data: {
|
||||||
userName: string
|
userName: string;
|
||||||
imageCode: string
|
imageCode: string;
|
||||||
uuid: string
|
uuid: string;
|
||||||
}) => {
|
}) => {
|
||||||
return httpRequest.post<{
|
return httpRequest.post<{
|
||||||
code: string
|
code: string;
|
||||||
msg: string
|
msg: string;
|
||||||
}>(`${baseUrl}/lt-web/xs/xcx/common/sendSms`, data)
|
}>(`${baseUrl}/lt-web/xs/xcx/common/sendSms`, data);
|
||||||
}
|
};
|
||||||
|
|
||||||
// 获取微信唯一编码
|
// 获取微信唯一编码
|
||||||
export const apiGetWxUserCode = (data: { code: string }) => {
|
export const apiGetWxUserCode = (data: { code: string }) => {
|
||||||
return httpRequest.post<{
|
return httpRequest.post<{
|
||||||
|
code: string;
|
||||||
|
msg: string;
|
||||||
data: {
|
data: {
|
||||||
openid: string
|
buyer: { buyerId: number; flag: number; token: string };
|
||||||
}
|
};
|
||||||
}>(`${baseUrl}/lt-web/xs/xcx/common/getWxUserCode`, data)
|
}>(`${baseUrl}/api-interface/app/user/login`, data);
|
||||||
}
|
};
|
||||||
|
|
||||||
// 登录
|
// 登录
|
||||||
type ManualLoginType = { loginType: number, userName: string, smsCode: string, openId: string }
|
type ManualLoginType = {
|
||||||
type LoginTypeData = { loginType: number, openId: string, code: string }
|
loginType: number;
|
||||||
export const apiLogin = <T extends LoginTypeData | ManualLoginType>(data: T) => {
|
userName: string;
|
||||||
|
smsCode: string;
|
||||||
|
openId: string;
|
||||||
|
};
|
||||||
|
type LoginTypeData = { loginType: number; openId: string; code: string };
|
||||||
|
export const apiLogin = <T extends LoginTypeData | ManualLoginType>(
|
||||||
|
data: T
|
||||||
|
) => {
|
||||||
return httpRequest.post<{
|
return httpRequest.post<{
|
||||||
code: string,
|
code: string;
|
||||||
msg: string,
|
msg: string;
|
||||||
data: {
|
data: {
|
||||||
userId: string
|
userId: string;
|
||||||
uniqueCode: string
|
uniqueCode: string;
|
||||||
userName: string,
|
userName: string;
|
||||||
phone: string
|
phone: string;
|
||||||
authorizeToken: string
|
authorizeToken: string;
|
||||||
}
|
};
|
||||||
}>(`${baseUrl}/lt-web/xs/xcx/common/login`, data)
|
}>(`${baseUrl}/lt-web/xs/xcx/common/login`, data);
|
||||||
}
|
};
|
||||||
|
|
||||||
// 退出登录
|
// 退出登录
|
||||||
export const apiLogout = () => {
|
export const apiLogout = () => {
|
||||||
return httpRequest.post(`${baseUrl}/lt-web/xs/xcx/common/logout`, {})
|
return httpRequest.post(`${baseUrl}/lt-web/xs/xcx/common/logout`, {});
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
"window": {
|
"window": {
|
||||||
"backgroundTextStyle": "light",
|
"backgroundTextStyle": "light",
|
||||||
"navigationBarBackgroundColor": "#fff",
|
"navigationBarBackgroundColor": "#fff",
|
||||||
"navigationBarTitleText": "优品尚",
|
"navigationBarTitleText": "购de着",
|
||||||
"navigationBarTextStyle": "black"
|
"navigationBarTextStyle": "black"
|
||||||
},
|
},
|
||||||
"sitemapLocation": "sitemap.json",
|
"sitemapLocation": "sitemap.json",
|
||||||
@ -12,13 +12,12 @@
|
|||||||
"desc": "获取当前的模糊地理位置"
|
"desc": "获取当前的模糊地理位置"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"requiredPrivateInfos": ["getFuzzyLocation"],
|
|
||||||
"pages": [
|
"pages": [
|
||||||
"pages/home/index",
|
"pages/home/index",
|
||||||
|
"pages/login/index",
|
||||||
"pages/category/index",
|
"pages/category/index",
|
||||||
"pages/shopping-cart/index",
|
"pages/shopping-cart/index",
|
||||||
"pages/mine/index",
|
"pages/mine/index",
|
||||||
"pages/login/index",
|
|
||||||
"pages/H5/index",
|
"pages/H5/index",
|
||||||
"pages/setup/index",
|
"pages/setup/index",
|
||||||
"pages/download/index"
|
"pages/download/index"
|
||||||
|
|||||||
BIN
miniprogram/assets/images/login/logo.jpg
Normal file
BIN
miniprogram/assets/images/login/logo.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 267 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 75 KiB |
@ -170,7 +170,7 @@ Page({
|
|||||||
onGoCommodity(e: WechatMiniprogram.TouchEvent) {
|
onGoCommodity(e: WechatMiniprogram.TouchEvent) {
|
||||||
wx.navigateTo({
|
wx.navigateTo({
|
||||||
url: `/pages/H5/index?url=${encodeURIComponent(
|
url: `/pages/H5/index?url=${encodeURIComponent(
|
||||||
`https://www.baidu.com?id=${e.currentTarget.dataset.id}`
|
`https://www.goudezhao.com/commodity-detail?id=${e.currentTarget.dataset.id}`
|
||||||
)}`,
|
)}`,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
import { apiGetAppCategoryList, apiGetHome } from "../../api/index/index";
|
import { apiGetAppCategoryList, apiGetHome } from "../../api/index/index";
|
||||||
import { setGlobalData } from "../../utils/common";
|
import { setGlobalData } from "../../utils/common";
|
||||||
|
import { onGoH5Page } from "../../utils/getUserInfo";
|
||||||
|
|
||||||
Page({
|
Page({
|
||||||
data: {
|
data: {
|
||||||
@ -9,7 +10,7 @@ Page({
|
|||||||
searchValue: "",
|
searchValue: "",
|
||||||
isScrolled: false,
|
isScrolled: false,
|
||||||
categories: [
|
categories: [
|
||||||
{ id: 2, name: "水果鲜花", categoryId: 1, icon: "/icons/fruit.png" },
|
/* { id: 2, name: "水果鲜花", categoryId: 1, icon: "/icons/fruit.png" },
|
||||||
{
|
{
|
||||||
id: 3,
|
id: 3,
|
||||||
name: "蔬菜豆制品",
|
name: "蔬菜豆制品",
|
||||||
@ -22,7 +23,7 @@ Page({
|
|||||||
{ id: 7, name: "巧克力", categoryId: 6, icon: "/icons/chocolate.png" },
|
{ id: 7, name: "巧克力", categoryId: 6, icon: "/icons/chocolate.png" },
|
||||||
{ id: 8, name: "薯片", icon: "/icons/chips.png" },
|
{ id: 8, name: "薯片", icon: "/icons/chips.png" },
|
||||||
{ id: 9, name: "饮料", icon: "/icons/drink.png" },
|
{ id: 9, name: "饮料", icon: "/icons/drink.png" },
|
||||||
{ id: 10, name: "休闲零食", icon: "/icons/snack.png" },
|
{ id: 10, name: "休闲零食", icon: "/icons/snack.png" }, */
|
||||||
],
|
],
|
||||||
flashSaleProducts: [
|
flashSaleProducts: [
|
||||||
{
|
{
|
||||||
@ -55,7 +56,7 @@ Page({
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
recommendedProducts: [
|
recommendedProducts: [
|
||||||
{
|
/* {
|
||||||
id: 1,
|
id: 1,
|
||||||
name: "[七夕]吻月粉红雪山玫瑰花束9枝",
|
name: "[七夕]吻月粉红雪山玫瑰花束9枝",
|
||||||
price: 79,
|
price: 79,
|
||||||
@ -87,7 +88,7 @@ Page({
|
|||||||
image: "/images/pepsi.jpg",
|
image: "/images/pepsi.jpg",
|
||||||
tags: ["真低价,放心购"],
|
tags: ["真低价,放心购"],
|
||||||
sales: "800+",
|
sales: "800+",
|
||||||
},
|
}, */
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
// 搜索框输入事件
|
// 搜索框输入事件
|
||||||
@ -125,12 +126,21 @@ Page({
|
|||||||
onGoCommodity(e: any) {
|
onGoCommodity(e: any) {
|
||||||
wx.navigateTo({
|
wx.navigateTo({
|
||||||
url: `/pages/H5/index?url=${encodeURIComponent(
|
url: `/pages/H5/index?url=${encodeURIComponent(
|
||||||
`https://www.baidu.com?id=${e.currentTarget.dataset.id}`
|
`https://h5.goudezhao.com/commodity-detail?id=${e.currentTarget.dataset.id}`
|
||||||
)}`,
|
)}`,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
// 添加到购物车
|
||||||
|
onAddToCart(e: any) {
|
||||||
|
onGoH5Page({
|
||||||
|
is_need_login: true,
|
||||||
|
type: "",
|
||||||
|
url: `/commodity-detail?id=${e.currentTarget.dataset.id}`,
|
||||||
|
});
|
||||||
|
// 这里可以添加购物车逻辑
|
||||||
|
},
|
||||||
handleGetHomePage() {
|
handleGetHomePage() {
|
||||||
apiGetHome().then((res: any) => {
|
apiGetHome({}).then((res: any) => {
|
||||||
// console.warn("----- my data is res222: ", res);
|
// console.warn("----- my data is res222: ", res);
|
||||||
this.setData({
|
this.setData({
|
||||||
recommendedProducts: res.data.rows.map((item: any) => ({
|
recommendedProducts: res.data.rows.map((item: any) => ({
|
||||||
|
|||||||
@ -62,7 +62,7 @@
|
|||||||
<text class="current-price">¥{{item.price}}</text>
|
<text class="current-price">¥{{item.price}}</text>
|
||||||
<text class="original-price" wx:if="{{item.originalPrice}}">¥{{item.originalPrice}}</text>
|
<text class="original-price" wx:if="{{item.originalPrice}}">¥{{item.originalPrice}}</text>
|
||||||
</view>
|
</view>
|
||||||
<van-icon name="add" color="#02CE26" size="48rpx" />
|
<van-icon name="add" color="#02CE26" size="48rpx" catchtap="onAddToCart" data-id="{{item.id}}" />
|
||||||
</view>
|
</view>
|
||||||
<!-- <view class="purchase-info">
|
<!-- <view class="purchase-info">
|
||||||
<text class="sales" wx:if="{{item.sales}}">{{item.sales}}人付款</text>
|
<text class="sales" wx:if="{{item.sales}}">{{item.sales}}人付款</text>
|
||||||
|
|||||||
@ -1,14 +1,14 @@
|
|||||||
.logo {
|
.logo {
|
||||||
width: 180rpx;
|
width: 350rpx;
|
||||||
display: flex;
|
display: flex;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
margin-top: 120rpx;
|
margin-top: 80rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.buttons {
|
.buttons {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
margin-top: 100rpx;
|
margin-top: 30rpx;
|
||||||
|
|
||||||
button {
|
button {
|
||||||
width: 590rpx;
|
width: 590rpx;
|
||||||
@ -38,7 +38,7 @@
|
|||||||
justify-content: center;
|
justify-content: center;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
margin-top: 120rpx;
|
margin-top: 10rpx;
|
||||||
|
|
||||||
|
|
||||||
.lz-input {
|
.lz-input {
|
||||||
@ -111,7 +111,7 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
margin-top: 78rpx;
|
margin-top: 28rpx;
|
||||||
font-size: 26rpx;
|
font-size: 26rpx;
|
||||||
color: #1e1f20;
|
color: #1e1f20;
|
||||||
|
|
||||||
|
|||||||
@ -1,237 +1,240 @@
|
|||||||
import { handleShareAppMsg } from '../../utils/configs'
|
import { handleShareAppMsg } from "../../utils/configs";
|
||||||
import { onGoH5Page } from '../../utils/getUserInfo'
|
import { onGoH5Page } from "../../utils/getUserInfo";
|
||||||
import { onMaiDian } from '../../utils/maiDian'
|
import { onMaiDian } from "../../utils/maiDian";
|
||||||
import { apiGetCaptchaImage, apiSendSms, apiGetWxUserCode, apiLogin } from '../../api/login/index'
|
import {
|
||||||
const H5Link = require('../../api/base').allBaseUrl.GDEnvs.web
|
apiGetCaptchaImage,
|
||||||
|
apiSendSms,
|
||||||
|
apiGetWxUserCode,
|
||||||
|
apiLogin,
|
||||||
|
} from "../../api/login/index";
|
||||||
|
const H5Link = require("../../api/base").allBaseUrl.GDEnvs.web;
|
||||||
|
|
||||||
Page({
|
Page({
|
||||||
data: {
|
data: {
|
||||||
logoUrl: '../../assets/images/login/logo.png',
|
logoUrl: "../../assets/images/login/logo.jpg",
|
||||||
checkedUrl: '../../assets/images/login/icon_check.svg',
|
checkedUrl: "../../assets/images/login/icon_check.svg",
|
||||||
errorIconUrl:'../../assets/images/login/error.svg',
|
errorIconUrl: "../../assets/images/login/error.svg",
|
||||||
codeUrl: '',
|
codeUrl: "",
|
||||||
isChecked: false,
|
isChecked: false,
|
||||||
loginType: 'auto',
|
loginType: "auto",
|
||||||
// manual
|
// manual
|
||||||
time: 60,
|
time: 60,
|
||||||
phone: '',
|
phone: "",
|
||||||
code: '',
|
code: "",
|
||||||
sms: '',
|
sms: "",
|
||||||
uuid: '',
|
uuid: "",
|
||||||
phoneError: false,
|
phoneError: false,
|
||||||
codeError: false,
|
codeError: false,
|
||||||
smsError: false,
|
smsError: false,
|
||||||
canLogin: false,
|
canLogin: false,
|
||||||
firstSend: true
|
firstSend: true,
|
||||||
},
|
},
|
||||||
/** 触发同意单选框 */
|
/** 触发同意单选框 */
|
||||||
handleCheck() {
|
handleCheck() {
|
||||||
this.setData({ isChecked: !this.data.isChecked })
|
this.setData({ isChecked: !this.data.isChecked });
|
||||||
},
|
},
|
||||||
/** 获取图形验证码 */
|
/** 获取图形验证码 */
|
||||||
async handleGetCode () {
|
async handleGetCode() {
|
||||||
const res = await apiGetCaptchaImage()
|
const res = await apiGetCaptchaImage();
|
||||||
try {
|
try {
|
||||||
this.setData({ codeUrl: 'data:image/gif;base64,' + res.data.img })
|
this.setData({ codeUrl: "data:image/gif;base64," + res.data.img });
|
||||||
this.setData({ uuid: res.data.uuid })
|
this.setData({ uuid: res.data.uuid });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/** 发送验证码 */
|
/** 发送验证码 */
|
||||||
async handleSendSms () {
|
async handleSendSms() {
|
||||||
if (!this.blurPhone()) {
|
if (!this.blurPhone()) {
|
||||||
wx.showToast({ title: '请填写手机号', icon: 'none' })
|
wx.showToast({ title: "请填写手机号", icon: "none" });
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
if (!this.data.firstSend) {
|
if (!this.data.firstSend) {
|
||||||
this.handleGetCode()
|
this.handleGetCode();
|
||||||
this.setData({ codeError: true })
|
this.setData({ codeError: true });
|
||||||
this.setData({ firstSend: true })
|
this.setData({ firstSend: true });
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
this.setData({ codeError: false })
|
this.setData({ codeError: false });
|
||||||
wx.showLoading({ title: '加载中' })
|
wx.showLoading({ title: "加载中" });
|
||||||
|
|
||||||
const params = {
|
const params = {
|
||||||
userName: this.data.phone,
|
userName: this.data.phone,
|
||||||
imageCode: this.data.code,
|
imageCode: this.data.code,
|
||||||
uuid: this.data.uuid
|
uuid: this.data.uuid,
|
||||||
}
|
};
|
||||||
const smsResult = await apiSendSms(params)
|
const smsResult = await apiSendSms(params);
|
||||||
if (smsResult.code === '1000') {
|
if (smsResult.code === "1000") {
|
||||||
this.setData({ firstSend: false })
|
this.setData({ firstSend: false });
|
||||||
} else {
|
} else {
|
||||||
this.setData({ codeError: true })
|
this.setData({ codeError: true });
|
||||||
wx.showToast({ title: smsResult.msg, icon: 'none' })
|
wx.showToast({ title: smsResult.msg, icon: "none" });
|
||||||
}
|
}
|
||||||
wx.hideLoading()
|
wx.hideLoading();
|
||||||
try {
|
try {
|
||||||
this.setData({ time: this.data.time - 1 })
|
this.setData({ time: this.data.time - 1 });
|
||||||
let timer = setInterval(() => {
|
let timer = setInterval(() => {
|
||||||
if (this.data.time === 0) {
|
if (this.data.time === 0) {
|
||||||
clearInterval(timer)
|
clearInterval(timer);
|
||||||
this.setData({ time: 60 })
|
this.setData({ time: 60 });
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
this.setData({ time: this.data.time - 1 })
|
this.setData({ time: this.data.time - 1 });
|
||||||
}, 1000)
|
}, 1000);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/** 跳转协议页面 */
|
/** 跳转协议页面 */
|
||||||
handelJumpToProtocol(e: any) {
|
handelJumpToProtocol(e: any) {
|
||||||
const url = `${H5Link}/operate/dynamic?id=${e.target.dataset.field}`
|
const url = `${H5Link}/operate/dynamic?id=${e.target.dataset.field}`;
|
||||||
onGoH5Page({ is_need_login: false, url })
|
onGoH5Page({ is_need_login: false, url });
|
||||||
},
|
},
|
||||||
/** 绑定手机号输入 */
|
/** 绑定手机号输入 */
|
||||||
handlePhoneInput(e: { detail: { value: string } }) {
|
handlePhoneInput(e: { detail: { value: string } }) {
|
||||||
this.setData({
|
this.setData({
|
||||||
phone: e.detail.value
|
phone: e.detail.value,
|
||||||
})
|
});
|
||||||
if (this.data.sms.length === 6 && this.data.phone.length === 11 && this.data.code.length === 4) {
|
if (
|
||||||
this.setData({ canLogin: true })
|
this.data.sms.length === 6 &&
|
||||||
}else{
|
this.data.phone.length === 11 &&
|
||||||
this.setData({ canLogin: false })
|
this.data.code.length === 4
|
||||||
|
) {
|
||||||
|
this.setData({ canLogin: true });
|
||||||
|
} else {
|
||||||
|
this.setData({ canLogin: false });
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
handleBindCode(e: { detail: { value: string } }) {
|
handleBindCode(e: { detail: { value: string } }) {
|
||||||
this.setData({ code: e.detail.value })
|
this.setData({ code: e.detail.value });
|
||||||
if (this.data.sms.length === 6 && this.data.phone.length === 11 && this.data.code.length === 4) {
|
if (
|
||||||
this.setData({ canLogin: true })
|
this.data.sms.length === 6 &&
|
||||||
}else{
|
this.data.phone.length === 11 &&
|
||||||
this.setData({ canLogin: false })
|
this.data.code.length === 4
|
||||||
|
) {
|
||||||
|
this.setData({ canLogin: true });
|
||||||
|
} else {
|
||||||
|
this.setData({ canLogin: false });
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
handleBindSms(e: { detail: { value: string } }) {
|
handleBindSms(e: { detail: { value: string } }) {
|
||||||
this.setData({ sms: e.detail.value })
|
this.setData({ sms: e.detail.value });
|
||||||
if (this.data.sms.length === 6 && this.data.phone.length === 11 && this.data.code.length === 4) {
|
if (
|
||||||
this.setData({ canLogin: true })
|
this.data.sms.length === 6 &&
|
||||||
}else{
|
this.data.phone.length === 11 &&
|
||||||
this.setData({ canLogin: false })
|
this.data.code.length === 4
|
||||||
|
) {
|
||||||
|
this.setData({ canLogin: true });
|
||||||
|
} else {
|
||||||
|
this.setData({ canLogin: false });
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/** 手机号输入框失焦检查 */
|
/** 手机号输入框失焦检查 */
|
||||||
blurPhone () {
|
blurPhone() {
|
||||||
const phone = this.data.phone
|
const phone = this.data.phone;
|
||||||
const reg = /^[1][3-9][0-9]{9}$/
|
const reg = /^[1][3-9][0-9]{9}$/;
|
||||||
const res = reg.test(phone)
|
const res = reg.test(phone);
|
||||||
if (!res) {
|
if (!res) {
|
||||||
this.setData({ phoneError: true })
|
this.setData({ phoneError: true });
|
||||||
} else {
|
} else {
|
||||||
this.setData({ phoneError: false })
|
this.setData({ phoneError: false });
|
||||||
}
|
}
|
||||||
return res
|
return res;
|
||||||
},
|
},
|
||||||
/** 手动登录 */
|
/** 手动登录 */
|
||||||
handleManualLogin () {
|
handleManualLogin() {
|
||||||
onMaiDian('其他手机号登录-曝光')
|
onMaiDian("其他手机号登录-曝光");
|
||||||
this.setData({ loginType: 'manual' })
|
this.setData({ loginType: "manual" });
|
||||||
this.handleGetCode()
|
this.handleGetCode();
|
||||||
},
|
},
|
||||||
/** 手动登录提交 */
|
/** 手动登录提交 */
|
||||||
async handleManualSubmit () {
|
async handleManualSubmit() {
|
||||||
if (!this.data.canLogin) return
|
if (!this.data.canLogin) return;
|
||||||
if (!this.data.isChecked) {
|
if (!this.data.isChecked) {
|
||||||
wx.showToast({ title: '请阅读并同意协议', icon: 'none' })
|
wx.showToast({ title: "请阅读并同意协议", icon: "none" });
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
const that = this
|
const that = this;
|
||||||
wx.showLoading({ title: '加载中' })
|
wx.showLoading({ title: "加载中" });
|
||||||
wx.login({
|
wx.login({
|
||||||
success(wxRes) {
|
success(wxRes) {
|
||||||
console.warn('wxRes:', wxRes)
|
console.warn("wxRes:", wxRes);
|
||||||
apiGetWxUserCode({ code: wxRes.code }).then(res => {
|
apiGetWxUserCode({ code: wxRes.code }).then((res) => {
|
||||||
apiLogin({
|
apiLogin({
|
||||||
loginType: 2,
|
loginType: 2,
|
||||||
userName: that.data.phone,
|
userName: that.data.phone,
|
||||||
smsCode: that.data.sms,
|
smsCode: that.data.sms,
|
||||||
openId: res.data.openid
|
openId: res.data.openid,
|
||||||
}).then(result => {
|
}).then((result) => {
|
||||||
if (result.code === '1000') {
|
if (result.code === "1000") {
|
||||||
onMaiDian('其他手机号登录-点击-登录')
|
onMaiDian("其他手机号登录-点击-登录");
|
||||||
wx.setStorage({
|
wx.setStorage({
|
||||||
key: 'user_info',
|
key: "user_info",
|
||||||
data: {
|
data: {
|
||||||
token: result.data.authorizeToken,
|
token: result.data.authorizeToken,
|
||||||
phone: result.data.phone,
|
phone: result.data.phone,
|
||||||
userName: result.data.userName,
|
userName: result.data.userName,
|
||||||
userId: result.data.userId,
|
userId: result.data.userId,
|
||||||
uniqueCode: result.data.uniqueCode
|
uniqueCode: result.data.uniqueCode,
|
||||||
},
|
},
|
||||||
success() {
|
success() {
|
||||||
wx.hideLoading()
|
wx.hideLoading();
|
||||||
wx.reLaunch({ url: '/pages/index/index' })
|
wx.reLaunch({ url: "/pages/index/index" });
|
||||||
}
|
},
|
||||||
})
|
});
|
||||||
} else {
|
} else {
|
||||||
that.handleGetCode()
|
that.handleGetCode();
|
||||||
that.setData({ codeError: true })
|
that.setData({ codeError: true });
|
||||||
that.setData({ smsError: true })
|
that.setData({ smsError: true });
|
||||||
that.setData({ firstSend: true })
|
that.setData({ firstSend: true });
|
||||||
wx.showToast({ title: result.msg, icon: 'none' })
|
wx.showToast({ title: result.msg, icon: "none" });
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
})
|
});
|
||||||
},
|
},
|
||||||
fail(wxResFail) {
|
fail(wxResFail) {
|
||||||
console.warn('wxResFail:', wxResFail)
|
console.warn("wxResFail:", wxResFail);
|
||||||
wx.showModal({ showCancel: true, content: wxResFail.errMsg })
|
wx.showModal({ showCancel: true, content: wxResFail.errMsg });
|
||||||
}
|
},
|
||||||
})
|
});
|
||||||
},
|
},
|
||||||
/** 一键登录 */
|
/** 一键登录 */
|
||||||
bindgetrealtimephonenumber(e: any) {
|
bindgetrealtimephonenumber(e: any) {
|
||||||
if (e.detail.errno === '1400001') {
|
if (e.detail.errno === "1400001") {
|
||||||
wx.showToast({ title: '登录失败,请联系客服', icon: 'error' })
|
wx.showToast({ title: "登录失败,请联系客服", icon: "error" });
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
if(!e.detail.code) return
|
if (!e.detail.code) return;
|
||||||
wx.showLoading({ title: '加载中' })
|
wx.showLoading({ title: "加载中" });
|
||||||
wx.login({
|
wx.login({
|
||||||
success(wxRes) {
|
success(wxRes) {
|
||||||
apiGetWxUserCode({ code: wxRes.code }).then(res => {
|
apiGetWxUserCode({ code: wxRes.code }).then((res) => {
|
||||||
apiLogin({
|
// onMaiDian("微信一键登录-点击-登录");
|
||||||
loginType: 1,
|
if (res.code !== "200")
|
||||||
openId: res.data.openid,
|
return wx.showToast({ title: res.msg, icon: "none" });
|
||||||
code: e.detail.code
|
wx.setStorage({
|
||||||
}).then(result => {
|
key: "user_info",
|
||||||
if (result.code === '1000') {
|
data: res.data.buyer,
|
||||||
onMaiDian('微信一键登录-点击-登录')
|
success() {
|
||||||
wx.setStorage({
|
wx.hideLoading();
|
||||||
key: 'user_info',
|
wx.navigateBack({ delta: 2 });
|
||||||
data: {
|
},
|
||||||
token: result.data.authorizeToken,
|
});
|
||||||
phone: result.data.phone,
|
});
|
||||||
userName: result.data.userName,
|
},
|
||||||
userId: result.data.userId,
|
});
|
||||||
uniqueCode: result.data.uniqueCode
|
|
||||||
},
|
|
||||||
success() {
|
|
||||||
wx.hideLoading()
|
|
||||||
wx.navigateBack({ delta: 2 })
|
|
||||||
}
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
wx.showToast({ title: result.msg, icon: 'none' })
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
handleUncheck() {
|
handleUncheck() {
|
||||||
wx.showToast({ title: '请阅读并同意协议', icon: 'none' })
|
wx.showToast({ title: "请阅读并同意协议", icon: "none" });
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* 用户点击右上角分享
|
* 用户点击右上角分享
|
||||||
*/
|
*/
|
||||||
onShareAppMessage() {
|
onShareAppMessage() {
|
||||||
handleShareAppMsg()
|
handleShareAppMsg();
|
||||||
},
|
},
|
||||||
onLoad() {
|
onLoad() {
|
||||||
wx.removeStorageSync('user_info')
|
wx.removeStorageSync("user_info");
|
||||||
onMaiDian('微信一键登录-曝光')
|
onMaiDian("微信一键登录-曝光");
|
||||||
}
|
},
|
||||||
})
|
});
|
||||||
|
|||||||
@ -70,4 +70,4 @@
|
|||||||
</view>
|
</view>
|
||||||
我已阅读并同意<text bindtap="handelJumpToProtocol" data-field="25">《注册协议》</text>&<text bindtap="handelJumpToProtocol" data-field="26">《隐私协议》</text>
|
我已阅读并同意<text bindtap="handelJumpToProtocol" data-field="25">《注册协议》</text>&<text bindtap="handelJumpToProtocol" data-field="26">《隐私协议》</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="tips">本产品不向学生提供贷款服务</view>
|
<view class="tips">本平台由杭州优品尚电商公司提供技术支持</view>
|
||||||
@ -6,7 +6,7 @@ Page({
|
|||||||
isManage: false,
|
isManage: false,
|
||||||
startX: 0,
|
startX: 0,
|
||||||
commodities: [
|
commodities: [
|
||||||
{
|
/* {
|
||||||
id: 1,
|
id: 1,
|
||||||
name: "水果鲜花是非得失发多少覅是范德萨司法的",
|
name: "水果鲜花是非得失发多少覅是范德萨司法的",
|
||||||
icon: "🍎",
|
icon: "🍎",
|
||||||
@ -16,7 +16,7 @@ Page({
|
|||||||
{ id: 3, name: "肉禽蛋", icon: "🥩", active: false },
|
{ id: 3, name: "肉禽蛋", icon: "🥩", active: false },
|
||||||
{ id: 4, name: "海鲜水产", icon: "🐟", active: false },
|
{ id: 4, name: "海鲜水产", icon: "🐟", active: false },
|
||||||
{ id: 5, name: "乳品烘焙", icon: "🥛", active: false },
|
{ id: 5, name: "乳品烘焙", icon: "🥛", active: false },
|
||||||
{ id: 6, name: "熟食快", icon: "🍱", active: false },
|
{ id: 6, name: "熟食快", icon: "🍱", active: false }, */
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -58,6 +58,22 @@ Page({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
onChangeNum(e: any) {
|
||||||
|
const { type, id } = e.currentTarget.dataset;
|
||||||
|
const data = this.data.commodities.map((item) => {
|
||||||
|
if (item.id === id) {
|
||||||
|
item.num = type === "minus" ? item.num - 1 : item.num + 1;
|
||||||
|
item.price = item.num * item.singlePrice;
|
||||||
|
}
|
||||||
|
return item;
|
||||||
|
});
|
||||||
|
this.setData({
|
||||||
|
commodities: data,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
onChangeCheckbox(e: any) {
|
||||||
|
// todo
|
||||||
|
},
|
||||||
// 删除商品
|
// 删除商品
|
||||||
onDeleteItem(e: any) {
|
onDeleteItem(e: any) {
|
||||||
const { id } = e.currentTarget.dataset;
|
const { id } = e.currentTarget.dataset;
|
||||||
@ -73,7 +89,10 @@ Page({
|
|||||||
name: item.productName,
|
name: item.productName,
|
||||||
icon: item.icon,
|
icon: item.icon,
|
||||||
originalPrice: item.originalPrice,
|
originalPrice: item.originalPrice,
|
||||||
price: item.singlePrice,
|
singlePrice: item.singlePrice,
|
||||||
|
price: item.allPrice,
|
||||||
|
num: item.num,
|
||||||
|
checked: false,
|
||||||
attribute: JSON.parse(item.skuInfo)
|
attribute: JSON.parse(item.skuInfo)
|
||||||
.map((item) => item.propertyValue)
|
.map((item) => item.propertyValue)
|
||||||
.join("-"),
|
.join("-"),
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
<view class="shopping-cart__container">
|
<view class="shopping-cart__container">
|
||||||
<view class="shopping-cart__item {{ item.active ? 'active' : '' }}" wx:for="{{commodities}}" wx:key="id" data-item="{{ item }}" bindtouchstart="handleTouchStart" bindtouchmove="handleTouchMove">
|
<view class="shopping-cart__item {{ item.active ? 'active' : '' }}" wx:for="{{commodities}}" wx:key="id" data-item="{{ item }}" bindtouchstart="handleTouchStart" bindtouchmove="handleTouchMove">
|
||||||
<view class="item__image">
|
<view class="item__image">
|
||||||
<van-checkbox value="{{ checked }}" bind:change="onChange">
|
<van-checkbox value="{{ item.checked }}" data-item="{{ item }}" bind:change="onChangeCheckbox">
|
||||||
</van-checkbox>
|
</van-checkbox>
|
||||||
<image class="image__icon" src="{{item.icon}}" />
|
<image class="image__icon" src="{{item.icon}}" />
|
||||||
</view>
|
</view>
|
||||||
@ -20,9 +20,9 @@
|
|||||||
<view class="line__price__origin">¥39.00</view>
|
<view class="line__price__origin">¥39.00</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="line__num">
|
<view class="line__num">
|
||||||
<van-icon name="minus" />
|
<van-icon name="minus" data-type="minus" data-id="{{ item.id }}" bindtap="onChangeNum" />
|
||||||
<view class="num__number">1</view>
|
<view class="num__number">{{item.num}}</view>
|
||||||
<van-icon name="plus" />
|
<van-icon name="plus" data-type="plus" data-id="{{ item.id }}" bindtap="onChangeNum" />
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@ -39,6 +39,7 @@
|
|||||||
<view class="footer__center">
|
<view class="footer__center">
|
||||||
<view class="footer__center__line">
|
<view class="footer__center__line">
|
||||||
<view class="footer__center__price">
|
<view class="footer__center__price">
|
||||||
|
<!-- ¥<text>50</text>.52 -->
|
||||||
¥<text>50</text>.52
|
¥<text>50</text>.52
|
||||||
</view>
|
</view>
|
||||||
<text class="footer__center__title">合计:</text>
|
<text class="footer__center__title">合计:</text>
|
||||||
|
|||||||
@ -1,82 +1,96 @@
|
|||||||
import { Base64 } from 'js-base64'
|
import { Base64 } from "js-base64";
|
||||||
|
|
||||||
export const wxInfo = wx.getSystemInfoSync()
|
export const wxInfo = wx.getSystemInfoSync();
|
||||||
export const mpInfo = wx.getAccountInfoSync()
|
export const mpInfo = wx.getAccountInfoSync();
|
||||||
export const miniProgramVersion = mpInfo.miniProgram.version || '1.0.0'
|
export const miniProgramVersion = mpInfo.miniProgram.version || "1.0.0";
|
||||||
|
const webUrl = require("../api/base").allBaseUrl.GDEnvs.web;
|
||||||
|
|
||||||
// 获取微信小程序token
|
// 获取微信小程序token
|
||||||
export const getWxToken = async() => {
|
export const getWxToken = async () => {
|
||||||
return new Promise(resolve => {
|
return new Promise((resolve) => {
|
||||||
wx.showLoading({ title: '加载中' })
|
wx.showLoading({ title: "加载中" });
|
||||||
wx.getStorage({
|
wx.getStorage({
|
||||||
key: 'user_info',
|
key: "user_info",
|
||||||
async success(res) {
|
async success(res) {
|
||||||
if (res.data.token) {
|
if (res.data.token) {
|
||||||
wx.hideLoading()
|
wx.hideLoading();
|
||||||
const envParams = { linktoken: 'miniProgram' }
|
const envParams = { linktoken: "miniProgram" };
|
||||||
// 获取经纬度
|
// 获取经纬度
|
||||||
const locationDataObj = wx.getStorageSync('locationData')
|
const locationDataObj = wx.getStorageSync("locationData");
|
||||||
if (locationDataObj) Object.assign(envParams, { ...locationDataObj })
|
if (locationDataObj) Object.assign(envParams, { ...locationDataObj });
|
||||||
|
|
||||||
// 获取小程序启动时的参数
|
// 获取小程序启动时的参数
|
||||||
const launchOptions = wx.getStorageSync('launch_options')
|
const launchOptions = wx.getStorageSync("launch_options");
|
||||||
if (launchOptions) Object.assign(envParams, { wxXcxLaunchOptions: launchOptions })
|
if (launchOptions)
|
||||||
|
Object.assign(envParams, { wxXcxLaunchOptions: launchOptions });
|
||||||
|
|
||||||
// 获取系统信息
|
// 获取系统信息
|
||||||
Object.assign(envParams, {
|
Object.assign(envParams, {
|
||||||
phoneType: wxInfo.model,
|
phoneType: wxInfo.model,
|
||||||
devType: wxInfo.platform === 'ios' ? 0 : 1,
|
devType: wxInfo.platform === "ios" ? 0 : 1,
|
||||||
devOS: wxInfo.platform,
|
devOS: wxInfo.platform,
|
||||||
devOSVersion: wxInfo.system,
|
devOSVersion: wxInfo.system,
|
||||||
devVersion: wxInfo.version,
|
devVersion: wxInfo.version,
|
||||||
appVersion: miniProgramVersion.replace(/\./g, '')
|
appVersion: miniProgramVersion.replace(/\./g, ""),
|
||||||
})
|
});
|
||||||
|
|
||||||
const extendParams = {
|
const extendParams = {
|
||||||
lzCode: 'CJTG_XCX_LZ',
|
lzCode: "CJTG_XCX_LZ",
|
||||||
uniqueCode: res.data.uniqueCode,
|
uniqueCode: res.data.uniqueCode,
|
||||||
userName: res.data.userName,
|
userName: res.data.userName,
|
||||||
userId: res.data.userId,
|
userId: res.data.userId,
|
||||||
token: res.data.token
|
token: res.data.token,
|
||||||
}
|
};
|
||||||
wx.getStorage({
|
wx.getStorage({
|
||||||
key: 'unique_code',
|
key: "unique_code",
|
||||||
success(res) {
|
success(res) {
|
||||||
if (res) {
|
if (res) {
|
||||||
Object.assign(extendParams, { uniqueCode: res })
|
Object.assign(extendParams, { uniqueCode: res });
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
})
|
});
|
||||||
const obj = { envParams, extendParams }
|
const obj = { envParams, extendParams };
|
||||||
const returnDataValue = encodeURIComponent(Base64.encode(JSON.stringify(obj)))
|
const returnDataValue = encodeURIComponent(
|
||||||
resolve(returnDataValue)
|
Base64.encode(JSON.stringify(obj))
|
||||||
|
);
|
||||||
|
resolve(returnDataValue);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
fail() {
|
fail() {
|
||||||
wx.hideLoading()
|
wx.hideLoading();
|
||||||
wx.navigateTo({ url: '/pages/login/index' })
|
wx.navigateTo({ url: "/pages/login/index" });
|
||||||
}
|
},
|
||||||
})
|
});
|
||||||
})
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
// 跳转H5页面
|
// 跳转H5页面
|
||||||
export const onGoH5Page = (params: any) => {
|
export const onGoH5Page = (params: any) => {
|
||||||
// url跳转链接,is_need_login是否需要登录:true是、false否,type页面类型:third三方
|
// url跳转链接,is_need_login是否需要登录:true是、false否,type页面类型:third三方
|
||||||
const { type, url, is_need_login } = params
|
const { type, url, is_need_login } = params;
|
||||||
if (is_need_login) {
|
if (is_need_login) {
|
||||||
getWxToken().then((res: any) => {
|
getWxToken().then((res: any) => {
|
||||||
if (res) {
|
if (res) {
|
||||||
const targetUrl = `${url}${/\?/.test(url) ? '&' : '?'}returnData=${res}`
|
const targetUrl = `${webUrl}${url}${
|
||||||
wx.navigateTo({ url: `/pages/H5/index?url=${encodeURIComponent(targetUrl)}` })
|
/\?/.test(url) ? "&" : "?"
|
||||||
|
}returnData=${res}`;
|
||||||
|
wx.navigateTo({
|
||||||
|
url: `/pages/H5/index?url=${encodeURIComponent(targetUrl)}`,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
} else {
|
} else {
|
||||||
if (type === 'third') {
|
if (type === "third") {
|
||||||
wx.navigateTo({ url: `/pages/H5/index?url=${encodeURIComponent(url)}` })
|
wx.navigateTo({ url: `/pages/H5/index?url=${encodeURIComponent(url)}` });
|
||||||
} else {
|
} else {
|
||||||
const targetUrl = `${url}${/\?/.test(url) ? '&' : '?'}jumpData=${encodeURIComponent(Base64.encode(JSON.stringify({ is_need_login: false })))}`
|
const targetUrl = `${url}${
|
||||||
wx.navigateTo({ url: `/pages/H5/index?url=${encodeURIComponent(targetUrl)}` })
|
/\?/.test(url) ? "&" : "?"
|
||||||
|
}jumpData=${encodeURIComponent(
|
||||||
|
Base64.encode(JSON.stringify({ is_need_login: false }))
|
||||||
|
)}`;
|
||||||
|
wx.navigateTo({
|
||||||
|
url: `/pages/H5/index?url=${encodeURIComponent(targetUrl)}`,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|||||||
@ -39,7 +39,7 @@
|
|||||||
"simulatorPluginLibVersion": {},
|
"simulatorPluginLibVersion": {},
|
||||||
"condition": {},
|
"condition": {},
|
||||||
"srcMiniprogramRoot": "miniprogram/",
|
"srcMiniprogramRoot": "miniprogram/",
|
||||||
"appid": "wx63bcaf38e587b406",
|
"appid": "wx75fa59c097bd3dfd",
|
||||||
"libVersion": "2.32.3",
|
"libVersion": "2.32.3",
|
||||||
"editorSetting": {
|
"editorSetting": {
|
||||||
"tabIndent": "insertSpaces",
|
"tabIndent": "insertSpaces",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user