Commit 0087f45d by 张立顺

Merge branch 'develop' of 192.168.3.233:saas_plus/business-assistant into develop

2 parents 2dd11d00 290b4a12
import api from "~/utils/request/request"; import api from "~/utils/request/request";
const serverApi = { const serverApi = {
createQrCode: "scrm.api.busassistant.activity.createQrCode", //生成二维码
createQrCode: "scrm.api.wechat.miniprogram.createQrcode",
// 解析二维码参数
sceneById:'scrm.api.wechat.get.scene.by.id'
}; };
// 拓客户
export const createQrCodeApi = (data) => { export const createQrCodeApi = (data) => {
return api.post( return api.post(
{ {
...@@ -14,3 +16,11 @@ export const createQrCodeApi = (data) => { ...@@ -14,3 +16,11 @@ export const createQrCodeApi = (data) => {
true true
); );
}; };
export const sceneByIdApi = (data) => {
return api.post(
{
method: serverApi.sceneById,
...data,
}
);
};
\ No newline at end of file \ No newline at end of file
/* login/index/components/Agree/Agree.wxss */ /* login/index/components/Agree/Agree.wxss */
.agree { .agree {
margin-top: 274rpx; position: fixed;
left: 0;
bottom: 100rpx;
width: 100%;
text { text {
color: #5092FF; color: #5092FF;
} }
......
...@@ -186,7 +186,7 @@ Component({ ...@@ -186,7 +186,7 @@ Component({
} = data, } = data,
validTime = 3600 * 24 * 7 * 1e3, validTime = 3600 * 24 * 7 * 1e3,
autoLoginFailureTime = Date.now() + validTime autoLoginFailureTime = Date.now() + validTime
if (autoLogin) { if (autoLogin && loginUserInfoList[0]) {
wx.$storage.set('auto_login_object', { wx.$storage.set('auto_login_object', {
failureTime: autoLoginFailureTime, failureTime: autoLoginFailureTime,
userName: formData.account, userName: formData.account,
......
/* login/index/components/LoginBox.wxss */ /* login/index/components/LoginBox.wxss */
.box { .box {
height: 800rpx; // height: 800rpx;
height: 750rpx;
.opacity-view { .opacity-view {
animation: opacity-view .5s forwards; animation: opacity-view .5s forwards;
...@@ -11,12 +12,14 @@ ...@@ -11,12 +12,14 @@
height: 458rpx; height: 458rpx;
position: absolute; position: absolute;
left: 151rpx; left: 151rpx;
top: 264rpx; // top: 264rpx;
top: 214rpx;
} }
.input-box { .input-box {
width: 540rpx; width: 540rpx;
padding-top: 352rpx; // padding-top: 352rpx;
padding-top: 302rpx;
margin: 0 auto; margin: 0 auto;
.title { .title {
......
/* login/index/components/TypeList.wxss */ /* login/index/components/TypeList.wxss */
.tips { .tips {
padding-top: 120rpx; padding-top: 100rpx;
text-align: center; text-align: center;
margin-bottom: 40rpx; margin-bottom: 40rpx;
} }
......
...@@ -28,6 +28,10 @@ const selectAccountLogin = ({ id, sessionId }) => { ...@@ -28,6 +28,10 @@ const selectAccountLogin = ({ id, sessionId }) => {
} }
/**设置登录信息 */ /**设置登录信息 */
const setLoginInfo = (userInfo, sessionId) => { const setLoginInfo = (userInfo, sessionId) => {
if(!userInfo) {
wx.$api.showToast('仅支持服务商类型账户登录')
return
}
setUserInfo(userInfo) setUserInfo(userInfo)
setSessionId(sessionId) setSessionId(sessionId)
loginSuccess() loginSuccess()
......
...@@ -107,7 +107,7 @@ Page({ ...@@ -107,7 +107,7 @@ Page({
code, code,
message message
}) => { }) => {
if (code == '0') { if (code == '0' && data.loginUserInfoList.length) {
const { const {
sessionId, sessionId,
loginUserInfoList loginUserInfoList
...@@ -116,11 +116,12 @@ Page({ ...@@ -116,11 +116,12 @@ Page({
} else { } else {
try { try {
const reload = await loginModal({ const reload = await loginModal({
message: message || '登录失败请重试', message: data.loginUserInfoList.length ? message : '登录失败请重试',
cancelText: '返回' cancelText: '返回'
}) })
if (reload) this.onShow() if (reload) this.onShow()
} catch (error) { } catch (error) {
wx.$storage.rm('auto_login_object')
wx.$router.reLaunch('login.index', obj) wx.$router.reLaunch('login.index', obj)
} }
} }
......
...@@ -4,7 +4,9 @@ const navStyle = "background-color: #fff"; ...@@ -4,7 +4,9 @@ const navStyle = "background-color: #fff";
import { senceData } from "~/pages/tab/index/constant/data"; import { senceData } from "~/pages/tab/index/constant/data";
import { IMG_URL } from "~/utils/constantData.js"; import { IMG_URL } from "~/utils/constantData.js";
import Draw from "~/utils/Draw.js"; import Draw from "~/utils/Draw.js";
import { createQrCodeApi } from "~/api/checkProduct.js"; import { createQrCodeApi,sceneByIdApi } from "~/api/checkProduct.js";
import utils from '~/utils/util.js'
Page({ Page({
/** /**
* 页面的初始数据 * 页面的初始数据
...@@ -86,12 +88,15 @@ Page({ ...@@ -86,12 +88,15 @@ Page({
isShow: true, isShow: true,
}); });
}, },
//接受跳转的路由参数 //接受跳转的路由参数(小程序页面跳转)
onRoute(options) { onRoute(options) {
console.log("分享options: ", options); console.log("分享options: ", options);
if(!options || utils.isEmptyObj(options))return
//选中场景的index,和产品的index //选中场景的index,和产品的index
let { actNum, activeNavIdx, apiData} = options; let { actNum, activeNavIdx, apiData} = options;
if(actNum&&activeNavIdx)return // if(actNum&&activeNavIdx)return
this.setData({ this.setData({
actNum, actNum,
activeNavIdx, activeNavIdx,
...@@ -132,11 +137,21 @@ Page({ ...@@ -132,11 +137,21 @@ Page({
// 下载海报 // 下载海报
async download() { async download() {
let { actNum, activeNavIdx, imgHeightArr } = this.data; let { actNum, activeNavIdx, imgHeightArr } = this.data;
let res = await createQrCodeApi({ let wx_user_info = wx.$storage.get('wx_user_info')
// console.log('wx_user_info: ', wx_user_info.appId);
let params = {
actNum, actNum,
activeNavIdx, activeNavIdx,
isShare: true, isShare: true,
}
let res = await createQrCodeApi({
appId:wx_user_info.appId,
path:'pages/checkProduct/checkProduct',
scene:JSON.stringify(params)
}); });
// console.log('res: ', res);
// let { actNum, imgHeightArr } = this.data; // let { actNum, imgHeightArr } = this.data;
//所有的长度 //所有的长度
...@@ -251,7 +266,7 @@ Page({ ...@@ -251,7 +266,7 @@ Page({
wx.nextTick(()=>{ wx.nextTick(()=>{
this.setData({ this.setData({
isShare: res.isShare, isShare: res.isShare,
// phone: res.phone, phone: res.phone,
}); });
}) })
...@@ -259,27 +274,29 @@ Page({ ...@@ -259,27 +274,29 @@ Page({
}, },
/** /**
* 生命周期函数--监听页面加载 () * 生命周期函数--监听页面加载 (扫码,分享链接)
*/ */
onLoad(options) { async onLoad(options) {
console.log('分享options12255565: ', options); console.log('分享options12255565: ', options);
// actNum,activeNavIdx isShare // actNum,activeNavIdx isShare
if(!options){ if(!options || utils.isEmptyObj(options))return
return // 解析二维码参数
} if(options.scene){
// 扫码进来
let { actNum, activeNavIdx, isShare, merchantId } = options;
console.log('isShare: ', isShare);
if (merchantId) {
this.setData({ this.setData({
isShow: false, isShare:true
isShare:true, })
}); let ercodeParams = await this.analysisQRcode(options.scene)
// console.log('ercodeParams: ', ercodeParams.scene);
options = utils.parseString(ercodeParams.scene)
// console.log('ercodeParams: ', options);
} }
if (isShare) {
// 扫码进来
let { actNum, activeNavIdx, isShare } = options;
if (isShare == 'true') {
this.setData({ this.setData({
isShow: false, isShow: false,
isShare:true,
}); });
} else { } else {
wx.showLoading({ wx.showLoading({
...@@ -289,12 +306,13 @@ Page({ ...@@ -289,12 +306,13 @@ Page({
this.setData({ this.setData({
actNum, actNum,
activeNavIdx activeNavIdx,
isShare:true
}) })
// 发请求 // 发请求
let senceItem = senceData[actNum]; let senceItem = senceData[actNum];
let item = senceData[actNum]?.productList[activeNavIdx]; let item = senceData[actNum]?.productList[activeNavIdx];
this.shareQuery = `sceneCode=${senceItem?.sceneCode}&productCode=${item?.productCode}&isShare=${isShare}&productDesc=${item?.productName}&category=${item?.category}&actNum=${actNum}&activeNavIdx=${activeNavIdx}`; this.shareQuery = `sceneCode=${senceItem?.sceneCode}&productCode=${item?.productCode}&isShare=${true}&productDesc=${item?.productName}&category=${item?.category}&actNum=${actNum}&activeNavIdx=${activeNavIdx}`;
this.shareTrackData = { this.shareTrackData = {
sceneCode: senceItem?.sceneCode, sceneCode: senceItem?.sceneCode,
productCode: item?.productCode, productCode: item?.productCode,
...@@ -305,11 +323,20 @@ Page({ ...@@ -305,11 +323,20 @@ Page({
// activeNavIdx, // activeNavIdx,
}; };
}, },
// 解析扫码进来参数
async analysisQRcode(str){
let id = str.split('%3D')[1]
let res = await sceneByIdApi({id})
// console.log('res: ', res);
return res
},
/** /**
* 生命周期函数--监听页面初次渲染完成 * 生命周期函数--监听页面初次渲染完成
*/ */
onReady() {}, onReady() {
},
/** /**
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
......
...@@ -173,12 +173,12 @@ Component({ ...@@ -173,12 +173,12 @@ Component({
USERAPI.getUserProfile(this.loginToken, detail) USERAPI.getUserProfile(this.loginToken, detail)
.then((result) => { .then((result) => {
// console.log(result) // console.log(result)
// let { phone } = result; let { phone } = result;
// let { // let {
wx.$storage.set('wx_user_info', result); wx.$storage.set('wx_user_info', result);
// } // }
this.triggerEvent("authorized", { this.triggerEvent("authorized", {
// phone, phone,
isShare: false, isShare: false,
}); });
// this. // this.
......
import { commonApi, equityApi } from '../api/api' import { commonApi, equityApi } from "../api/api";
// import { // import {
// sopApi, // sopApi,
...@@ -6,7 +6,7 @@ import { commonApi, equityApi } from '../api/api' ...@@ -6,7 +6,7 @@ import { commonApi, equityApi } from '../api/api'
// bigdatautilApi, // bigdatautilApi,
// equityApi // equityApi
// } from '../api/api' // } from '../api/api'
import $router from '../router/index' import $router from "../router/index";
/** /**
* 日期格式化 * 日期格式化
...@@ -14,115 +14,147 @@ import $router from '../router/index' ...@@ -14,115 +14,147 @@ import $router from '../router/index'
*/ */
Date.prototype.format = function (fmt) { Date.prototype.format = function (fmt) {
let o = { let o = {
'M+': this.getMonth() + 1, //月份 "M+": this.getMonth() + 1, //月份
'd+': this.getDate(), //日 "d+": this.getDate(), //日
'h+': this.getHours(), //小时 "h+": this.getHours(), //小时
'm+': this.getMinutes(), //分 "m+": this.getMinutes(), //分
's+': this.getSeconds(), //秒 "s+": this.getSeconds(), //秒
//季度 //季度
'q+': Math.floor((this.getMonth() + 3) / 3), "q+": Math.floor((this.getMonth() + 3) / 3),
S: this.getMilliseconds() //毫秒 S: this.getMilliseconds(), //毫秒
} };
if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + '').substr(4 - RegExp.$1.length)) if (/(y+)/.test(fmt))
fmt = fmt.replace(
RegExp.$1,
(this.getFullYear() + "").substr(4 - RegExp.$1.length)
);
for (let k in o) { for (let k in o) {
if (new RegExp('(' + k + ')').test(fmt)) fmt = fmt.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ('00' + o[k]).substr(('' + o[k]).length)) if (new RegExp("(" + k + ")").test(fmt))
fmt = fmt.replace(
RegExp.$1,
RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length)
);
} }
return fmt return fmt;
} };
/**触底加载 */ /**触底加载 */
const onReachBottom = (obj, callBack) => { const onReachBottom = (obj, callBack) => {
let _this = $router.getPageInstance() let _this = $router.getPageInstance();
let { pageNum, total, pageSize, nothing } = obj let { pageNum, total, pageSize, nothing } = obj;
if (!total && !pageNum) { if (!total && !pageNum) {
console.error('total&&pageNum为必传') console.error("total&&pageNum为必传");
return return;
} }
if (!pageSize) pageSize = 10 if (!pageSize) pageSize = 10;
if (!nothing) nothing = 'nothing' if (!nothing) nothing = "nothing";
if (Math.ceil(total / pageSize) > pageNum) { if (Math.ceil(total / pageSize) > pageNum) {
_this.setData({ _this.setData({
pageNum: pageNum + 1 pageNum: pageNum + 1,
}) });
callBack() callBack();
} else { } else {
_this.setData({ _this.setData({
[nothing]: true [nothing]: true,
}) });
} }
} };
/**是否全面屏 */ /**是否全面屏 */
const isFullSucreen = isComponents => { const isFullSucreen = (isComponents) => {
const thisPage = $router.getPageInstance() const thisPage = $router.getPageInstance();
const routerList = $router.getRouterList() const routerList = $router.getRouterList();
const router = routerList.find(item => item.url === `/${thisPage.route}`) const router = routerList.find((item) => item.url === `/${thisPage.route}`);
let key = `${router.url.replace('/', '')}.html` let key = `${router.url.replace("/", "")}.html`;
let val = false let val = false;
if (__wxConfig && __wxConfig.page && __wxConfig.page[key]) { if (__wxConfig && __wxConfig.page && __wxConfig.page[key]) {
let { navigationStyle } = __wxConfig.page[key].window let { navigationStyle } = __wxConfig.page[key].window;
wx.getSystemInfo({ wx.getSystemInfo({
success(res) { success(res) {
if (res.platform != 'android') { if (res.platform != "android") {
let { statusBarHeight, screenHeight, windowHeight } = res let { statusBarHeight, screenHeight, windowHeight } = res;
if (navigationStyle && navigationStyle == 'custom') { if (navigationStyle && navigationStyle == "custom") {
windowHeight = windowHeight - thisPage.data.navHeight || 0 windowHeight = windowHeight - thisPage.data.navHeight || 0;
} }
//兼容自定义标题 //兼容自定义标题
val = router.isTab ? screenHeight - windowHeight - statusBarHeight - 32 > 72 : screenHeight - windowHeight > 72 val = router.isTab
if (isComponents) val = screenHeight - windowHeight > 72 ? screenHeight - windowHeight - statusBarHeight - 32 > 72
: screenHeight - windowHeight > 72;
if (isComponents) val = screenHeight - windowHeight > 72;
} }
}, },
fail(err) { fail(err) {
return false return false;
} },
}) });
} }
return val return val;
} };
/**节流 */ /**节流 */
const throttle = (fn, gapTime) => { const throttle = (fn, gapTime) => {
if (gapTime == null || gapTime == undefined) { if (gapTime == null || gapTime == undefined) {
gapTime = 1500 gapTime = 1500;
} }
let _lastTime = null let _lastTime = null;
// 返回新的函数 // 返回新的函数
return function () { return function () {
let _nowTime = +new Date() let _nowTime = +new Date();
if (_nowTime - _lastTime > gapTime || !_lastTime) { if (_nowTime - _lastTime > gapTime || !_lastTime) {
fn.apply(this, arguments) //将this和参数传给原函数 fn.apply(this, arguments); //将this和参数传给原函数
_lastTime = _nowTime _lastTime = _nowTime;
} }
} };
} };
/**删除对象里的null值 */ /**删除对象里的null值 */
const clearObjNull = options => { const clearObjNull = (options) => {
let obj = {} let obj = {};
Object.keys(options).map(e => { Object.keys(options).map((e) => {
if (options[e] != null && options[e] != undefined) { if (options[e] != null && options[e] != undefined) {
if (typeof options[e] == 'object') { if (typeof options[e] == "object") {
Object.keys(options[e]).map(key => { Object.keys(options[e]).map((key) => {
if (options[e][key] == null || options[e][key] == undefined) delete options[e][key] if (options[e][key] == null || options[e][key] == undefined)
}) delete options[e][key];
});
} }
obj[e] = options[e] obj[e] = options[e];
} }
}) });
return obj return obj;
} };
/**
* 判断是否是空对象
* @param {*} obj 传进来的对象
* @returns
*/
const isEmptyObj = (obj) => {
return JSON.stringify(obj) === "{}";
};
// 解析参数成对象 "actNum=1&activeNavIdx=0&isShare=true"
const parseString = (str) => {
if (!str) return;
let obj = {};
let strArr = str.split("&");
strArr.forEach((item) => {
console.log("item: ", item);
let keyArr = item.split("=");
obj[keyArr[0]] = keyArr[1];
});
return obj;
};
/**获取图片版本号 */ /**获取图片版本号 */
const getImgVersion = () => { const getImgVersion = () => {};
}
const Util = { const Util = {
getImgVersion, getImgVersion,
onReachBottom, onReachBottom,
isFullSucreen, isFullSucreen,
clearObjNull, clearObjNull,
throttle throttle,
} isEmptyObj,
export default Util parseString,
};
export default Util;
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!