Commit b7debe51 by 前端

Merge branch 'develop' into 'master'

Develop

See merge request !7
2 parents efa6efd0 a2043580
Showing 226 changed files with 2640 additions and 397 deletions
project.config.json
project.private.config.json
sitemap.json
# local env files
.env.local
.env.*.local
# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw*
## 正式版appid wx2c28337db96364d2
## 体验版appid wx24ebae5768e74138
\ No newline at end of file
import api from '~/utils/request/request'
import ssoApi from './ssoApi'
const common = 'scrm.api.carlife.common.'
module.exports = {
ssoApi,
commonApi: {
/**上传图片
*/
......
/**
* 申请门店开通
*/
// import api from '~/utils/request/request'
// const serverApi = {
// productByscene:'scrm.api.busassistant.activity.productByscene'
// }
// export const productBysceneApi = (data) =>{
// return api.post(
// {
// method: serverApi.productByscene,
// ...data
// },
// true
// )
// }
import api from '~/utils/request/request'
// const { appId } = wx.getAccountInfoSync().miniProgram
const CODE = {
platformEntrance: 'BUSINESS_ASSISTANT',
productCode: 'PC00c3'
}
class applyApi {
/**申请门店 */
merchantApply(data) {
return api.post(
{
method: 'scrm.api.busassistant.merchant.apply',
...data
}
// true
)
}
}
export default applyApi
import applyApi from './applyApi.js'
export default new applyApi()
import api from "~/utils/request/request";
const serverApi = {
//生成二维码
createQrCode: "scrm.api.wechat.miniprogram.createQrcode",
// 解析二维码参数
sceneById:'scrm.api.wechat.get.scene.by.id'
};
export const createQrCodeApi = (data) => {
return api.post(
{
method: serverApi.createQrCode,
...data,
},
true
);
};
export const sceneByIdApi = (data) => {
return api.post(
{
method: serverApi.sceneById,
...data,
}
);
};
\ No newline at end of file
/**
* 拓客户,看线索接口
*/
import api from '~/utils/request/request'
const path = 'scrm.api.sso.weapp.'
module.exports = {
/**wx.login登录 */
jsCodeLogin(data) {
return api.post(
{
method: `${path}jscode.login`,
...data
},
true
)
},
/**授权用户信息 */
authUserInfo(data) {
return api.post(
{
method: 'scrm.api.sso.weapp.auth.userinfo',
...data
},
true
)
},
/**授权手机号 */
authUserPhone(data) {
return api.post(
{
method: `${path}auth.phone`,
...data
},
true
)
},
/**退出 */
logout() {
return api.post(
{
method: `scrm.api.sso.user.logout`
},
true
)
},
//保存用户授权信息
saveuserProfile(data) {
return api.post(
{
method: `scrm.api.wechat.auth.userProfile.save`,
...data
},
true
)
},
/**更新客户手机号 */
updataCustomerPhone(data) {
return api.post({
method: `scrm.api.sso.weapp.mark.phone`,
const serverApi = {
// 拓客户
productByscene: 'scrm.api.busassistant.activity.findSceneProductStatus',
// 看线索
unread: 'scrm.api.busassistant.clue.unread', //获取未读线索数量
page: 'scrm.api.busassistant.clue.page', //分页查询线索列表
read: 'scrm.api.busassistant.clue.read', //标记线索已读
tag: 'scrm.api.busassistant.clue.tag', //线索标记意向客户
battleMessage: 'scrm.api.busassistant.message.battleMessage' //获取最新战报消息
}
// 拓客户
const productBysceneApi = data => {
return api.post(
{
method: serverApi.productByscene,
...data
},
true
)
}
// 看线索
const unreadApi = data => {
return api.post(
{
method: serverApi.unread,
...data
},
true
)
}
const pageApi = data => {
return api.post(
{
method: serverApi.page,
...data
},
true
)
}
const readApi = data => {
return api.post(
{
method: serverApi.read,
...data
},
true
)
}
const tagApi = data => {
return api.post(
{
method: serverApi.tag,
...data
},
true
)
}
const battleMessageApi = data => {
return api.post({
method: serverApi.battleMessage,
...data
})
}
module.exports = {
/** 线索埋点数据上报
* operationType 操作类型(0:分享 1:浏览 2:申请活动)
*/
reportData(data = {}, operationType = 0) {
return api.post({
method: 'scrm.api.busassistant.clue.report',
...data,
operationType,
operationDate: new Date().format('yyyy-MM-dd hh:mm:ss')
})
}
},
productBysceneApi,
unreadApi,
pageApi,
readApi,
tagApi,
battleMessageApi
}
import mineApi from './mine.js'
export default new mineApi()
import api from '~/utils/request/request'
// const { appId } = wx.getAccountInfoSync().miniProgram
const CODE = {
platformEntrance: 'BUSINESS_ASSISTANT',
productCode: 'PC00c3'
}
class mineApi {
/**分页查询客户列表 */
merchantCustomInfo(data) {
return api.post(
{
method: 'scrm.api.boutiquecoupon.merchantCustomInfo.page',
...data
}
// true
)
}
/** 保存客户信息 */
saveMerchantCustomInfo(data) {
return api.post(
{
method: 'scrm.api.boutiquecoupon.merchantCustomInfo.save',
...data
}
// true
)
}
/** 消息盒子列表 */
messageBoxPage(data) {
return api.post(
{
method: 'scrm.api.busassistant.messageBox.page',
...data
}
// true
)
}
/** 是否有未读消息 */
messageBoxPageIsRead(data) {
return api.post(
{
method: 'scrm.api.busassistant.messageBox.isread',
...data
}
// true
)
}
}
export default mineApi
import outputApi from './output.js'
export default new outputApi()
import api from '~/utils/request/request'
// const { appId } = wx.getAccountInfoSync().miniProgram
const CODE = {
platformEntrance: 'BUSINESS_ASSISTANT',
productCode: 'PC00c3'
}
class outputApi {
/** 获取服务商(生意助手看产值)我的客户页总收益 */
getMerchantTotal(data) {
return api.post({
method: 'scrm.api.boutiquecoupon.partnermerchant.getMerchantTotal',
...data
})
}
/** 分页获取服务商(生意助手看产值)我的客户页数据 */
getCustomerPageList(data) {
return api.post({
method: 'scrm.api.boutiquecoupon.partnermerchant.customerPageList',
...data
})
}
/** 服务商(生意助手看产值)我的客户详情数据 */
getCustomerDetail(data) {
return api.post({
method: 'scrm.api.boutiquecoupon.partnermerchant.getCustomerDetail',
...data
})
}
/**获取园区店开通场景数据 */
getSignMerchant(data) {
return api.post(
{
method: 'scrm.api.boutiquecoupon.getSceneTotal.byYqMerchantId',
...data
}
// true
)
}
/**获取服务商(生意助手看产值)我的门店页数据 */
partnerMerchantTotal(data) {
return api.post(
{
method: 'scrm.api.boutiquecoupon.partnermerchant.yqList',
...data
},
true
)
}
/** 查找可开通的产品 */
getNoOpenPro(data) {
return api.post({
method: 'scrm.api.busassistant.activity.findNotOpenProducts',
...data
})
}
/**查询场景和产品的开通状态 */
getSceneProStatus(data) {
return api.post({
method: 'scrm.api.busassistant.activity.findSceneProductStatus',
...data
})
}
/** 申请开通活动*/
applyActivity(data) {
return api.post({
method: 'scrm.api.busassistant.activity.apply',
...data
})
}
/** 查询门店众筹活动产值 */
getActivityRevenue(data) {
return api.post({
method: 'scrm.api.busassistant.merchant.activity.Revenue',
...data
})
}
/** 店面汇总-下载海报 */
getPosterUrl(data) {
return api.post({
method: 'scrm.api.busassistant.crowdFunding.poster',
...data
})
}
}
export default outputApi
// import api from '../api/request'
import api from '~/utils/request/request'
const { appId } = wx.getAccountInfoSync().miniProgram
const {
appId
} = wx.getAccountInfoSync().miniProgram
const CODE = {
platformEntrance: 'BUSINESS_ASSISTANT',
productCode: 'PC00c3'
}
class UsersApi {
/**调用后台接口获取用户信息 */
async login() {
return this.getWxCode().then(({ code }) => {
return api.post(
{
method: 'scrm.api.sso.weapp.jscode.login',
/**调用后台接口获取用户信息js_code换取sessionId */
async wxCodeLogin() {
const appEnter = wx.getEnterOptionsSync()
try {
if (appEnter.scene === 1154 && appEnter.mode === 'singlePage') throw 'login:fail rejected due to no permission currently'
const {
code
} = await this.getWxCode()
return await api.post({
method: 'scrm.api.sso.wechat.applets.jscode.login',
appId,
code
},
true
)
})
} catch (error) {
console.log(error)
return Promise.reject()
}
}
/**退出登录 */
logout() {
return api.post({
method: 'scrm.api.sso.wechat.applets.logout'
},
true
)
}
/**调用接口获取登录凭证(code)。通过凭证进而换取用户登录态信息,包括用户在当前小程序的唯一标识(openid)、微信开放平台帐号下的唯一标识(unionid,若当前小程序已绑定到微信开放平台帐号)及本次登录的会话密钥(session_key)等。用户数据的加解密通讯需要依赖会话密钥完成。 */
getWxCode() {
......@@ -24,39 +44,129 @@ class UsersApi {
})
})
}
/**授权手机号 */
async authUserPhone(detail, sessionId) {
if (!sessionId) {
wx.$util.showToast('缺少sessionId')
/**授权手机号登录 */
async authUserPhone(detail, loginToken) {
if (!loginToken) {
wx.$api.showToast('缺少loginToken')
Promise.reject()
return
}
if (detail.errMsg && detail.errMsg == 'getPhoneNumber:fail user deny') Promise.reject()
delete detail.errMsg
if (detail.iv && detail.encryptedData) {
wx.$util.showLoading()
detail.sessionId = sessionId
return api.post(
{
method: 'scrm.api.sso.weapp.auth.phone',
...detail
detail.loginToken = loginToken
return api.post({
method: 'scrm.api.sso.wechat.applets.auth.phone',
...detail,
platformEntrance: 'BUSINESS_ASSISTANT' // 平台标识:生意助手-BUSINESS_ASSISTANT,门店助手-STORE_ASSISTANT
},
true
)
} else Promise.reject()
}
/**更新客户手机号 */
updataCustomerPhone() {
let customerId = wx.$storage.get('srcm_shopmall_customer_id'),
merchantId = wx.$storage.get('srcm_shopmall_merchant_id')
api
.post({
method: 'scrm.api.sso.weapp.mark.phone',
customerId,
merchantId
})
.then(() => {
wx.removeStorageSync('srcm_shopmall_customer_id')
})
/**账号密码登录 */
async accountLogin(data = {}) {
return api.post({
method: 'scrm.api.sso.wechat.applets.password.login',
...data,
...CODE
},
true
)
}
/** 手机号获取短信验证码 */
getSmsCode(mobile) {
return api.post({
method: 'scrm.api.sso.wechat.applets.sms.get.code',
mobile
},
true
)
}
/** 手机号短信验证码登录 */
phoneSmsLogin(data = {}) {
return api.post({
method: 'scrm.api.sso.wechat.applets.sms.login',
...data,
source: 'MINIAPP',
platformEntrance: 'BUSINESS_ASSISTANT'
},
true
)
}
/** 获取登录账号列表 */
getAccountList(sessionId) {
return api.post({
method: 'scrm.api.sso.wechat.applets.listSelectAccount',
...CODE,
sessionId
},
true
)
}
/**
* 选择账号登录(手机绑定多个账号时) */
selectAccountLogin(data) {
return api.post({
method: 'scrm.api.sso.wechat.applets.selectAccountLogin',
...CODE,
...data
},
true
)
}
/**检查sessionId 是否过期 */
checkSession() {
return api.post({
method: 'scrm.api.sso.login.status.check'
},
true
)
}
/** 超级管理员切换账号 */
adminSelectLogin(data) {
return api.post({
method: 'scrm.api.sso.super.administrator.select.login',
...CODE,
...data
}
// true
)
}
/** 超管切换子账号 */
switchSubLoginInfo(data) {
return api.post({
method: 'scrm.api.sso.wechat.applets.switch.subLoginInfo',
...CODE,
...data
})
}
/**获取微信用户信息 */
async getWXUserInfo() {
let wx_user_info = wx.$storage.get('wx_user_info')
if (!wx_user_info) {
const data = await this.getUserProfile()
wx.$storage.set('wx_user_info', data)
return data
} else return wx_user_info
}
/** 手机号授权解析(单纯解析内容返回前端)
* 只传loginToken就返回unionId和openid
* 传加密信息就解析手机号
*/
async getUserProfile(loginToken, detail = {}) {
if (detail.errMsg && detail.errMsg == 'getPhoneNumber:fail user deny') Promise.reject()
delete detail.errMsg
if (!loginToken) {
let res = await this.wxCodeLogin()
loginToken = res.data
}
detail.loginToken = loginToken
return api.post({
method: 'scrm.api.sso.wechat.applets.phone.grant.analysis',
...detail,
platformEntrance: 'BUSINESS_ASSISTANT'
})
}
}
export default UsersApi
export default UsersApi
\ No newline at end of file
// app.js
import util from './utils/util.js'
import '~/router/routerBefore.js'
import router from './router/index.js'
// 初始化sentry
import sentryInit from '~/utils/sentryConfig/sentryInit'
sentryInit()
import util from './utils/util'
import wxApi from './utils/utils_wx'
import '~/router/routerBefore'
import router from './router/index'
// 有问题 前后顺序不能随意调整
// console.log(test)
import { setSystem_info } from '~/utils/cache/storageApi'
// console.log(setSystem_info)
// 判断小程序是否需要更新
import getUpdateManager from './utils/lib/wxUpdateManager'
// 埋点
import './utils/track/Track'
// import './utils/track/Track'
import eventbus from './utils/evenbus'
......@@ -24,11 +31,19 @@ promisifyAll()
import { Storage } from './utils/cache/storage'
const $Storage = new Storage()
//全局分享
import './utils/share'
//监听网络状态
import './utils/network'
App({
onLaunch(options) {
/**挂载到wx对象 */
/**挂载到wx对象 */
wx.$authStatus = false
wx.$util = util
wx.$api = wxApi
wx.$router = router
wx.$storage = $Storage /** 挂载全局缓存方法 */
wx.$eventbus = eventbus
......@@ -45,6 +60,5 @@ App({
wx.$router.goHome()
},
onHide() {},
globalData: {
}
globalData: {}
})
{
"pages": ["login/loading/loading","pages/tab/index/index", "pages/tab/output/output", "pages/tab/mine/mine", "pages/webView/webView","login/index/index"],
"pages": [
"login/loading/loading",
"pages/tab/index/index",
"pages/tab/output/output",
"pages/tab/mine/mine",
"pages/webView/webView",
"pages/apply/apply",
"login/index/index",
"login/accountItems/accountItems",
"pages/checkProduct/checkProduct",
"packageOutput/pages/summary/summary",
"packageOutput/pages/openBusiness/openBusiness",
"pages/mineDetail/customerManagement/customerManagement",
"pages/mineDetail/messageBox/messageBox"
],
"requiredPrivateInfos": ["getLocation"],
"lazyCodeLoading": "requiredComponents",
"window": {
......@@ -12,7 +26,8 @@
"selectedColor": "#3666FE",
"backgroundColor": "#FFFFFF",
"borderStyle": "white",
"list": [{
"list": [
{
"pagePath": "pages/tab/index/index",
"text": "拓客户",
"iconPath": "images/home.png",
......@@ -21,8 +36,8 @@
{
"pagePath": "pages/tab/output/output",
"text": "看产值",
"iconPath": "images/mall.png",
"selectedIconPath": "images/mall_active.png"
"iconPath": "images/output.png",
"selectedIconPath": "images/output_active.png"
},
{
"pagePath": "pages/tab/mine/mine",
......@@ -34,7 +49,11 @@
},
"subpackages": [],
"usingComponents": {
"tab": "/components/Tab/Tab",
"navigation-bar": "/components/NavigationBar/NavigationBar",
"popup": "/components/Popup/Popup",
"nothing-tips": "/components/Nothing-tips/nothingTips",
"crowdfund-poster": "/components/CrowdfundPoster/CrowdfundPoster"
},
"style": "v2",
"resolveAlias": {
......@@ -45,6 +64,5 @@
"scope.userLocation": {
"desc": "你的位置信息将用于小程序位置接口的效果展示"
}
},
"plugins": {}
}
\ No newline at end of file
}
}
@import "/common.wxss";
@import "/style/common.wxss";
page {
background-color: #F7F7F7;
color: #282829;
font-size: 28rpx;
--themeColor: #F13C3D;
--btnColor: #FC5B32;
--btnColor: #3666FE;
--borderRadius: 8rpx;
--margin: 32rpx;
}
......
// components/Authorize/Authorize.js
import {
componentsMixin
} from '../../mixins/index'
Component({
behaviors: [componentsMixin],
/**
* 组件的属性列表
*/
......@@ -39,7 +35,7 @@ Component({
}
},
observers: {
'show': function (newVal) {
show: function (newVal) {
this.setData({
openSet: newVal
})
......@@ -48,9 +44,7 @@ Component({
/**
* 组件的初始数据
*/
data: {
},
data: {},
/**
* 组件的方法列表
*/
......@@ -58,15 +52,10 @@ Component({
/**
* 禁止滑动
*/
noScroll: wx.$util.noScroll(),
noScroll(){},
cancel(e) {
let {
confirm
} = e.currentTarget.dataset
let {
buttonType,
title
} = this.data
let { confirm } = e.currentTarget.dataset
let { buttonType, title } = this.data
let _this = this
if (buttonType == 'getUserInfo' && confirm) {
wx.getUserProfile({
......@@ -87,11 +76,7 @@ Component({
/**检验是否已授权位置 */
check() {
const _this = this
let {
buttonType,
scopeType,
autoOpen
} = this.properties
let { buttonType, scopeType, autoOpen } = this.properties
if (buttonType != 'getPhoneNumber') {
let type = `scope.${scopeType}`
buttonType = 'openSetting'
......@@ -128,12 +113,9 @@ Component({
}
})
}
},
/**授权手机号 */
getPhoneNumber({
detail
}) {
getPhoneNumber({ detail }) {
console.log(detail)
this.triggerEvent('getphonenumber', detail)
}
......@@ -144,4 +126,4 @@ Component({
},
hide: function () {}
}
})
\ No newline at end of file
})
......@@ -2,9 +2,7 @@
import Calendar from './Calendar_Function'
import _component_ from './Static_Properties'
const CalendarFunction = Symbol('CalendarFunction')
import {componentsMixin } from '../../mixins/index'
Component({
behaviors:[componentsMixin],
/**
* 组件的属性列表
*/
......@@ -24,7 +22,7 @@ Component({
this[CalendarFunction].setCalenderBodyHeight()
},
showCalendar(e) {
let type = e && e.currentTarget && e.currentTarget.dataset.type || ''
let type = (e && e.currentTarget && e.currentTarget.dataset.type) || ''
let result = type === 'show'
if (!result) {
this.setData({
......@@ -44,29 +42,19 @@ Component({
}
},
dateChange(e) {
let {
current
} = e.detail
let { current } = e.detail
this.setData({
current
})
},
choose(e) {
let {
dateType,
minDate,
maxDate
} = this.data
let {
data
} = e.currentTarget.dataset
let { dateType, minDate, maxDate } = this.data
let { data } = e.currentTarget.dataset
if ((minDate && Date.parse(minDate) > Date.parse(data)) || (maxDate && Date.parse(maxDate) < Date.parse(data))) return
this[CalendarFunction][dateType](e)
},
done() {
let {
dateType
} = this.data
let { dateType } = this.data
this[CalendarFunction].done(dateType)
},
changeDate(e) {
......@@ -87,4 +75,4 @@ Component({
attached() {
this[CalendarFunction] = new Calendar(this)
}
})
\ No newline at end of file
})
// packageOutput/pages/summary/components/CrowdfundPoster/CrowdfundPoster.js
import Draw from '~/utils/Draw'
Component({
/**
* 组件的属性列表
*/
properties: {
item: {
type: Object,
observer(n) {
console.log(n, '=================')
n.posterUrl && this.getImageInfo(n)
}
}
},
/**
* 组件的初始数据
*/
data: {},
/**
* 组件的方法列表
*/
methods: {
getImageInfo(n, width, height) {
wx.$api.showLoading('处理中')
let that = this
wx.getImageInfo({
src: `${n.posterUrl}?v=${Date.now()}`,
success: function (res) {
console.log(res)
// w = res.width
// h = res.height
that.init(n, res.width, res.height)
},
fail: function (res) {
console.log(res)
wx.$api.showToast('生成失败')
}
})
},
async init(n, ImgWidth, ImgHeight) {
let proportion = ImgWidth / 247
let actualHeight = ImgHeight / proportion
console.log(actualHeight)
n.activityName = n.activityName.length > 12 ? `${n.activityName.substring(0, 12)}...` : n.activityName
const drawfun = new Draw(
{
width: 279,
// height: 554
height: 82 + actualHeight
},
this
),
{ userInfo } = wx.$storage.get(),
merchantName = userInfo.merchantName.length > 12 ? `${userInfo.merchantName.substring(0, 12)}...` : userInfo.merchantName,
res = await drawfun.begin({
imageList: [
{
x: 0,
y: 0,
width: 279,
height: 66,
url: 'https://img02.glsx.com.cn/weapp/resource/saas/business-assistant/output/poster-bg.png'
},
{
x: 16,
y: 70,
width: 247,
height: actualHeight,
url: n.posterUrl
}
],
textList: [
{
x: 12,
y: 14,
fontSize: 14,
color: '#2D2D33',
text: merchantName,
textBaseline: 'top'
},
{
x: 12,
y: 36,
fontSize: 14,
color: '#1B233D',
text: n.activityName,
textBaseline: 'top',
fontWeight: 500
},
{
x: 14 + drawfun.getTextWidth(n.activityName, 14) + 9,
y: 37,
fontSize: 10,
color: '#4466F0',
text: '众筹',
textBaseline: 'top',
border: {
width: 1,
color: '#4466F0',
radius: 2,
padding: [2, 5],
opacity: 0.5
}
}
]
})
console.log(res)
wx.hideLoading()
this.setData({
poster: res.path,
show: true
})
},
download() {
const filePath = this.data.poster,
_this = this
wx.saveImageToPhotosAlbum({
filePath,
success() {
wx.$api.showToast('保存成功')
},
fail(err) {
const auth = _this.selectComponent('#auth')
auth.check()
}
})
},
hide() {
this.setData({
show: false,
poster: ''
})
},
noScroll() {},
authFail(e) {
this.setData({
showAuth: true
})
}
}
})
{
"component": true,
"usingComponents": {
"authorize":"/components/Authorize/Authorize"
}
}
\ No newline at end of file
/* packageOutput/pages/summary/components/CrowdfundPoster/CrowdfundPoster.wxss */
.layout {
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 998;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
.bg {
position: absolute;
width: 100%;
height: 100%;
z-index: -1;
background: rgba(28, 27, 35, 0.60);
}
.poster {
width: 558rpx;
// height: 60%;
height: 1108rpx;
overflow: scroll;
border-radius: 8rpx;
}
.btn {
width: 320rpx;
height: 88rpx;
line-height: 88rpx;
background: #3666FE;
// background-image: linear-gradient(-60deg, #556AF5 0%, #7197FF 100%);
border-radius: 16rpx;
font-weight: 500;
font-size: 32rpx;
color: #FFFFFF;
text-align: center;
margin-top: 32rpx;
}
.tips {
margin: 16rpx 80rpx 0;
font-size: 24rpx;
color: #FFFFFF;
line-height: 36rpx;
}
}
\ No newline at end of file
<block wx:if="{{show}}">
<!-- catchtouchmove="noScroll" -->
<view class="layout">
<view class="bg" bindtap="hide" />
<view class="poster">
<!-- <scroll-view scroll-x="false" scroll-y="true" style="height: 100%"> -->
<image src="{{poster}}" mode="widthFix" />
<!-- </scroll-view> -->
</view>
<view class="btn" bindtap="download">保存至相册</view>
<view class="tips">提示:这是您的专属活动海报,请下载转发给门店员工注册并参与活动分享。请不要将此海报转发给非相关活动参与者,避免活动数据泄漏。</view>
</view>
</block>
<authorize
scopeType="writePhotosAlbum"
bindfail="authFail"
show="{{showAuth}}"
isShowCheck="{{false}}"
id="auth" />
// components/GlCell/GlCell.js
Component({
/**
* 组件的属性列表
*/
properties: {
label: String,
labelWidth: String,
border: Boolean,
haveArrow: Boolean,
value: String,
valueAlign: String,
required: Boolean,
placeholder: String,
iconSrc: String,
labelStyle: String,
cellHeight: {
type: Boolean,
value: true
},
requiredBefore: {
type: Boolean,
value: true
},
requiredAfter: {
type: Boolean,
value: false,
observer: function (n, o) {
if (n) {
this.setData({
requiredBefore: false
})
}
}
},
disabled: Boolean
},
/**
* 组件的初始数据
*/
data: {},
/**
* 组件的方法列表
*/
methods: {
click(e) {
if (this.data.disabled) return
this.triggerEvent('click')
},
titleClick() {
this.triggerEvent('titleClick')
}
}
})
<view class='cell-box'>
<view class="cell {{cellHeight?'cellHeight': ''}} {{border?'border':''}}" bindtap="click">
<view class='cell-label' style="width:{{labelWidth}};{{labelStyle}}" bindtap="titleClick">
<text wx:if='{{required&&requiredBefore}}' class='required'>*</text>
{{label||'标题'}}
<image class="titleIcon" wx:if="{{iconSrc}}" src="{{iconSrc}}" />
<text wx:if='{{required&&requiredAfter}}' class='required'>*</text>
</view>
<view class='cell-value ' style="width:calc(100% - {{labelWidth}});">
<view class='value {{valueAlign}} {{haveArrow}}'>
<view class='slot'>
<slot/>
</view>
<block wx:if="{{value}}">
<view class='details'>{{value}}</view>
</block>
<block wx:if="{{placeholder}}">
<view class='placeholder'>{{placeholder}}</view>
</block>
</view>
<image wx:if='{{haveArrow}}' class='arrow' src="../images/arrow-x.png" />
</view>
</view>
</view>
/* components/GlCell/GlCell.wxss */
.cell-box {
background: #fff;
font-size: 28rpx;
color: #333333;
box-sizing: border-box;
}
.cell {
width: 100%;
box-sizing: border-box;
display: flex;
/* padding-left: 40rpx; */
align-items: center;
}
.cellHeight {
height: 120rpx;
}
.cell.border {
border-bottom: 2rpx solid rgba(195, 195, 195, .3);
}
.cell-label {
width: 25%;
}
.titleIcon {
width: 34rpx;
height: 34rpx;
}
.cell-value {
width: 75%;
position: relative;
height: 100%;
}
.cell-value .false {
padding-right: 40rpx !important;
}
.value {
width: 100%;
height: 100%;
display: flex;
align-items: center;
padding-right: 70rpx;
box-sizing: border-box;
}
.required {
color: #f00;
}
.details,
.placeholder {
display: none;
}
.slot:empty+.details,
.slot:empty+.placeholder {
display: block;
width: 100%;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.placeholder {
color: #C3C3C3;
}
.cell-value .right {
justify-content: flex-end;
height: 100%;
box-sizing: border-box;
}
.cell-value .right .details,
.cell-value .right .placeholder {
text-align: right;
}
.slot {
width: 100%;
}
.slot:empty {
display: none;
}
.arrow {
position: absolute;
right: 40rpx;
top: 50%;
transform: translateY(-50%);
width: 28rpx;
height: 26rpx;
}
\ No newline at end of file
......@@ -6,6 +6,7 @@ Component({
properties: {
navStyle: String,
custom: Boolean,
showBack: Boolean,
pageTitle: {
type: String,
value: '',
......@@ -46,7 +47,13 @@ Component({
right,
width,
top
} = wx.getMenuButtonBoundingClientRect()
} = wx.getMenuButtonBoundingClientRect(),
currentPages = getCurrentPages(), {
showBack
} = this.data
if (showBack && currentPages.length > 1) this.setData({
SHOWBACK: true
})
let navigationBarHeight = height + ((top - statusBarHeight) * 2) + 4 // 4
let navigationBarPadding = screenWidth - right
let navigationBarWidth = screenWidth - (navigationBarPadding * 2 + width) - width
......@@ -68,7 +75,6 @@ Component({
}) {
let navHeight = navigationBarHeight + statusBarHeight
const thisPage = wx.$router.getPageInstance()
const currentPages = getCurrentPages()
this.triggerEvent('navbarReady', {
height: navHeight,
statusBarHeight
......@@ -80,9 +86,9 @@ Component({
navHeight,
statusBarHeight
})
if (currentPages.length == 1 && !thisPage.rootName) thisPage.setData({
showHomeBtn: true
})
},
back() {
wx.$router.back()
}
},
lifetimes: {
......
<view class="navigation-bar" id="navigation-bar"
style="padding-top:{{statusBarHeight}}px;height:{{navigationBarHeight}}px;{{navStyle}}">
<block wx:if="{{!custom}}">
<view class="navigation-bar-box" wx:if="{{showNavBar}}" style="{{navigationBarStyle}}">
<view class="navigation-bar-titleText" style="{{navigationBarTextWidth}}">
<slot></slot>
</view>
</view>
</block>
<block wx:else>
<slot></slot>
</block>
</view>
\ No newline at end of file
<view class="navigation-bar" id="navigation-bar" style="padding-top:{{statusBarHeight}}px;height:{{navigationBarHeight}}px;{{navStyle}}">
<block wx:if="{{!custom}}">
<view class="navigation-bar-box" wx:if="{{showNavBar}}" style="{{navigationBarStyle}}">
<block wx:if="{{SHOWBACK}}">
<view class="back " bindtap="back">
<image class="img" src="./images/icon-back.png" />
</view>
</block>
<view class="navigation-bar-titleText" style="{{navigationBarTextWidth}}">
<slot/>
</view>
</view>
</block>
<block wx:else>
<slot/>
</block>
</view>
/* components/navigationBar/navigationBar.wxss */
.navigation-bar{
.navigation-bar {
position: fixed;
top: 0;
left: 0;
......@@ -8,16 +8,18 @@
background-color: #fff;
transition: all .15s;
}
.navigation-bar-box{
.navigation-bar-box {
position: relative;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
box-sizing: border-box;
}
.navigation-bar-titleText{
.navigation-bar-titleText {
color: #333333;
overflow: hidden;
text-overflow: ellipsis;
......@@ -27,18 +29,29 @@
text-align: center;
letter-spacing: 1rpx;
}
.back-box{
.back-box {
width: 76rpx;
height: 100%;
position: absolute;
left: 0;
top: 0;
}
.back{
.back {
position: absolute;
left: 20rpx;
left: 0;
top: 50%;
transform: translateY(-50%);
width: 36rpx;
height: 36rpx;
width: 100rpx;
/* height: 34rpx; */
height: 100%;
display: flex;
align-items: center;
justify-content: center;
}
.back .img {
width: 16rpx;
height: 34rpx;
}
\ No newline at end of file
// components/Nothing-tips/nothingTips.js
Component({
/**
* 组件的属性列表
*/
properties: {
tips: String,
bg: String
},
/**
* 组件的初始数据
*/
data: {},
/**
* 组件的方法列表
*/
methods: {}
})
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file
/* components/Nothing-tips/nothingTips.wxss */
.nothingCon {
width: 100vw;
height: 100vh;
background-color: #fff;
display: flex;
flex-direction: column;
align-items: center;
// justify-content: center;
.bg {
width: 512rpx;
height: 512rpx;
}
.tips {
margin-top: -15rpx;
font-size: 24rpx;
color: #CCCED1;
text-align: center;
}
}
\ No newline at end of file
<!-- components/Nothing-tips/nothingTips.wxml -->
<view class="nothingCon">
<image
wx:if="{{bg}}"
class="bg"
src="{{bg}}"
webp></image>
<view wx:if="{{tips}}" class="tips">{{tips}}</view>
<slot/>
</view>
// tabWorkOrder/pages/createOrder/createOrderComponents/Popup/Popup.js
import {
componentsMixin
} from '../../mixins/index'
Component({
behaviors: [componentsMixin],
/**
* 组件的属性列表
*/
......@@ -23,14 +19,13 @@ Component({
}, 0.2 * 1000)
} else {
let hideTab = wx.$hideTab
console.log(hideTab)
// console.log(hideTab)
this.setData({
showPopup: true,
close: false,
hideTab
})
}
}
},
title: String,
......@@ -48,7 +43,7 @@ Component({
* 组件的初始数据
*/
data: {
// hideTab: false
},
/**
......@@ -60,17 +55,16 @@ Component({
this.setData({
show: false
})
this.triggerEvent('hidePopup')
},
confirm() {
this.triggerEvent('confirm')
}
},
attached() {
const {
isTab
} = wx.$router.getRouterList().find(item => item.url === `/${wx.$router.getPageInstance().route}`)
const { isTab } = wx.$router.getRouterList().find(item => item.url === `/${wx.$router.getPageInstance().route}`)
this.setData({
isTab
})
},
})
\ No newline at end of file
}
})
......@@ -45,7 +45,7 @@
}
.popup-slot {
height: calc(100% - 200rpx);
height: calc(100% - 100rpx);
}
.popup-slot.isFullSucreen {
......
// pages/tab/output/components/sceneBox/sceneBox.js
import { IMG_URL } from '~/utils/constantData'
Component({
/**
* 组件的属性列表
*/
properties: {
sceneActive: {
type: Number,
value: -1
},
hasOpenIcon: {
type: Boolean,
value: true
},
hasLockIcon: {
type: Boolean,
value: true
},
formData: {
type: Object,
value: () => {}
},
scenePriceList: {
type: Array,
value: () => []
}
},
/**
* 组件的初始数据
*/
data: {
IMGURL: IMG_URL,
openedIcon: `${IMG_URL}/output/openedIcon.png`,
custSceneList: [
{
title: '新车洽谈场景',
subTitle: '1.0新车权益升级'
},
{
title: '新车交付场景',
subTitle: '1.1新车精品升级'
},
{
title: '0-6个月',
subTitle: '1.2次新车膨胀金活动'
},
{
title: '6个月以上',
subTitle: '1.3售后直播众筹活动'
}
]
},
/**
* 组件的方法列表
*/
methods: {
handleClick(e) {
let { idx } = e.currentTarget.dataset
this.triggerEvent('handleSceneChange', { sceneIdx: idx })
}
}
})
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file
<!-- pages/tab/output/components/sceneBox/sceneBox.wxml -->
<view class="flex scene">
<view
class="scene-item {{ (formData['scene' + (index + 1)] && hasOpenIcon) ? 'open' : ''}} {{ (sceneActive != -1 && sceneActive == index + 1) ? 'active' : ''}}"
wx:for="{{custSceneList}}"
wx:key="index"
bindtap="handleClick"
data-idx="{{index + 1}}">
<!-- && sceneActive != (index + 1) -->
<view wx:if="{{hasOpenIcon && formData['scene' + (index + 1)]}}" class="open-icon">
<image src="{{openedIcon}}" webp></image>
</view>
<image webp wx:if="{{formData['scene' + (index + 1)]}}" class="scene-img" src="{{IMGURL}}output/caract0{{index + 1}}.png?v={{img_version}}" ></image>
<view wx:else class="no-open-img">
<image webp wx:if="{{hasLockIcon}}" class="lock-img" src="{{IMGURL}}output/carlock0{{index + 1}}.png?v={{img_version}}" ></image>
<image webp wx:else="" class="scene-img" src="{{IMGURL}}output/car0{{index + 1}}.png?v={{img_version}}" ></image>
</view>
<view class="scene-title {{formData['scene' + (index + 1)] ? '' : 'on-open'}}">
{{item.title}}
</view>
<view>{{item.subTitle}}</view>
<view class="total-price" wx:if="{{scenePriceList.length}}">
¥ {{scenePriceList[index].total}}
</view>
</view>
</view>
/* pages/tab/output/components/sceneBox/sceneBox.wxss */
.flex {
display: flex;
}
.scene {
text-align: center;
width: 100%;
}
.scene-item {
box-sizing: border-box;
position: relative;
width: 25%;
/* flex: 1; */
background: #F7F8FC;
margin-right: 4rpx;
font-size: 18rpx;
/* color: #8A8C90; */
color: #323436;
padding: 32rpx 0 28rpx;
border-radius: 12rpx;
font-weight: 500;
/* margin-bottom: 20rpx; */
}
.scene-item:last-child {
margin-right: 0;
}
.scene-title {
font-size: 24rpx;
height: 44rpx;
line-height: 44rpx;
margin: 10rpx 0 4rpx;
}
/* 已开通 - start */
.open.scene-item {
background: #F0F7FF;
}
.open-icon {
box-sizing: border-box;
position: absolute;
top: 0;
right: 0;
width: 78rpx;
height: 78rpx;
/* left: 0.5rpx;
top: 0.5rpx;
width: 56rpx;
height: 32rpx;
line-height: 24rpx;
background: #FEEBD6;
border-radius: 6rpx 0 8rpx 0;
font-size: 18rpx;
font-weight: 600;
color: #EF971E;
padding: 4rpx; */
}
/* 已开通 - end */
/* 选中 - start */
.active.scene-item {
background-image: linear-gradient(145deg, #F0F7FF 0%, #FFFFFF 73%);
border: 2rpx solid #3666FE;
box-shadow: 0 4rpx 8rpx 0 rgba(180, 186, 204, 0.32), 0 8rpx 20rpx 0 rgba(180, 186, 204, 0.40);
}
.active::after {
position: absolute;
left: 50%;
bottom: -17rpx;
display: block;
content: "";
width: 16rpx;
height: 16rpx;
/* border-radius: 4rpx; */
border-bottom: 1px solid var(--btnColor);
border-right: 1px solid var(--btnColor);
transform: rotate(45deg) translateX(-50%);
background-color: #fff;
}
/* 选中 - end */
.scene-title {
color: #323436;
}
/* .scene-title.on-open {
color: #8A8C90;
} */
.no-open-img {
position: relative;
}
.scene-img {
width: 56rpx;
height: 56rpx;
}
.lock-img {
width: 92rpx;
height: 64rpx;
}
.total-price {
height: 40rpx;
line-height: 40rpx;
margin-top: 22rpx;
font-size: 24rpx;
color: #3666FE;
font-weight: 600;
}
.notOpened {
color: #8A8C90;
}
\ No newline at end of file
// components/SearchBox/SearchBox.js
import {componentsMixin } from '../../mixins/index';
Component({
behaviors: [componentsMixin],
/**
* 组件的属性列表
*/
properties: {
placeholder: {
type: String,
value: "请输入搜索内容",
value: '请输入搜索内容'
},
value: {
type: String,
value: "",
value: '',
observer(n) {
this.setData({
inputValue: n,
});
},
inputValue: n
})
}
},
searchType: {
type: Number,
value: 1,
value: 1
},
couponDetails: Boolean,
couponDetails: Boolean
},
/**
* 组件的初始数据
*/
data: {
inputValue: "",
inputValue: ''
},
/**
......@@ -38,29 +36,29 @@ Component({
*/
methods: {
input(e) {
let { value } = e.detail;
let { value } = e.detail
this.setData({
inputValue: value,
});
inputValue: value
})
},
blur(e) {
let { inputValue } = this.data;
let { inputValue } = this.data
this.setData({
inputValue,
});
inputValue
})
},
clear() {
this.setData({
inputValue: "",
});
inputValue: ''
})
},
confirm(e) {
let { value } = e.detail;
this.triggerEvent("search", value);
let { value } = e.detail
this.triggerEvent('search', value)
},
search(e) {
let { value } = e.currentTarget.dataset;
this.triggerEvent("search", value);
},
},
});
let { value } = e.currentTarget.dataset
this.triggerEvent('search', value)
}
}
})
// components/SearchInput/SearchInput.js
import {componentsMixin } from '../../mixins/index'
Component({
behaviors:[componentsMixin],
/**
* 组件的属性列表
*/
......@@ -22,9 +20,7 @@ Component({
/**
* 组件的初始数据
*/
data: {
},
data: {},
/**
* 组件的方法列表
......@@ -39,9 +35,7 @@ Component({
})
},
input(e) {
let {
value
} = e.detail
let { value } = e.detail
this.setValue(value)
this.triggerEvent('input', {
value
......@@ -55,9 +49,7 @@ Component({
},
emit(e) {
let {
detail:{
value
},
detail: { value },
type
} = e
this.setData({
......@@ -69,4 +61,4 @@ Component({
})
}
}
})
\ No newline at end of file
})
// components/Select/Select.js
Component({
properties: {
// 这里定义了innerText属性,属性值可以在组件使用时指定
innerText: {
type: String,
value: 'default value'
}
},
data: {
// 这里是一些组件内部数据
someData: {}
},
methods: {
// 这里是一个自定义方法
customMethod: function () {}
}
})
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file
/* components/Select/Select.wxss */
.com-selectBox {
width: 200px;
}
.com-sContent {
border: 1px solid #e2e2e2;
background: white;
font-size: 16px;
position: relative;
height: 30px;
line-height: 30px;
}
.com-sImg {
position: absolute;
right: 10px;
top: 11px;
width: 16px;
height: 9px;
transition: all .3s ease;
}
.com-sTxt {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
padding: 0 20px 0 6px;
font-size: 14px;
}
.com-sList {
background: white;
width: inherit;
position: absolute;
border: 1px solid #e2e2e2;
border-top: none;
box-sizing: border-box;
z-index: 3;
max-height: 120px;
overflow: auto;
}
.com-sItem {
height: 30px;
line-height: 30px;
border-top: 1px solid #e2e2e2;
padding: 0 6px;
text-align: left;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
font-size: 14px;
}
.com-sItem:first-child {
border-top: none;
}
\ No newline at end of file
<!-- components/Select/Select.wxml -->
<view class='com-selectBox'>
<view class='com-sContent' bindtap='selectToggle'>
<view class='com-sTxt'>{{nowText}}</view>
<image src='../../public/image/index/jinru1@2x.png' class='com-sImg' animation="{{animationData}}" />
</view>
<view class='com-sList' wx:if="{{selectShow}}">
<view
wx:for="{{propArray}}"
data-index="{{index}}"
wx:key=''
class='com-sItem'
bindtap='setText'>
{{item.text}}
</view>
</view>
</view>
// components/Tab/Tab.js
import {componentsMixin } from '../../mixins/index'
// behaviors: [LocationBehavior],
import { imgUrlMixin } from '~/mixins/index'
Component({
behaviors:[componentsMixin],
behaviors: [imgUrlMixin],
options: {
addGlobalClass: true
},
/**
* 组件的属性列表
*/
properties: {
outClassName:String,
tab: Array,
openScroll: Boolean,
tabHeight: {
type: Boolean,
value: false
},
productHeight: {
type: Boolean,
value: false
},
index: {
type: Number,
observer: function (n) {
......@@ -17,10 +30,16 @@ Component({
})
}
},
itemWidth: String,
align: {
type: String,
default: ''
}
value: ''
},
// 是否有红点
unreadClueCount: {
type: Number,
value: 0
},
},
/**
......@@ -30,20 +49,24 @@ Component({
count: 0,
to: ''
},
// lifetimes:{
// attached: function() {
// console.log('unreadClueCount',this.data.unreadClueCount)
// }
// },
/**
* 组件的方法列表
*/
methods: {
click(e) {
let {
count
} = e.currentTarget.dataset
let { count } = e.currentTarget.dataset
this.setData({
count,
to: `to-${count}`
to: `to-${count}`,
unreadClueCount:0
})
this.triggerEvent('click', count)
}
}
})
\ No newline at end of file
})
<wxs src="./Tab.wxs" module="filterUtils" />
<block wx:if="{{openScroll}}">
<scroll-view class="tab-box {{align}}" scroll-x enable-flex scroll-with-animation scroll-into-view="{{to}}">
<block wx:for="{{tab}}" wx:key="index">
<view class="tab {{index==count?'active':''}}" bindtap="click" data-count="{{index}}" id="to-{{index}}" >
<view class="text" >{{item}}</view>
<!-- <view class="text" style="width:{{38 * item.length + 20}}rpx;">{{item}}</view> -->
<view class="line"></view>
</view>
</block>
</scroll-view>
<scroll-view class="tab-box {{align}} {{outClassName}}" style="{{productHeight ? 'height: 72rpx;' : ''}}" scroll-x enable-flex scroll-with-animation scroll-into-view="{{to}}" enhanced="{{true}}" show-scrollbar="{{false}}">
<block wx:for="{{tab}}" wx:key="index">
<view class="tab {{index==count?'active':''}}" bindtap="click" data-count="{{index}}" id="to-{{index}}">
<view class="text" style="{{productHeight ? 'height: 60rpx;' : ''}}">{{item}}</view>
<!-- <view class="text" style="width:{{38 * item.length + 20}}rpx;">{{item}}</view> -->
<view class="line" style="{{productHeight ? 'height: 4rpx;' : ''}}" />
</view>
</block>
</scroll-view>
</block>
<block wx:else>
<view class="tab-box flex">
<block wx:for="{{tab}}" wx:key="index">
<view class="tab {{index==count?'active':''}}" bindtap="click" data-count="{{index}}">
<view class="text text-center">{{item}}</view>
<view class="line"></view>
</view>
</block>
</view>
<view class="tab-box flex" style="{{tabHeight ? 'height: 60rpx;' : ''}}">
<block wx:for="{{tab}}" wx:key="index">
<view class="tab {{index==count?'active':''}}" style="width:{{itemWidth}}; {{index == 0 ? 'margin-left: 32rpx;' : ''}}" bindtap="click" data-count="{{index}}">
<view class="text text-center" style="{{tabHeight ? 'height: 60rpx;' : ''}}">{{item}}</view>
<view class="line" style="{{tabHeight ? 'margin-top: 6rpx;' : ''}}" />
<!-- -->
<view wx:if="{{filterUtils.hasRedpoint(unreadClueCount)}}" class="redpoint" />
</view>
</block>
</view>
</block>
\ No newline at end of file
var hasRedpoint = function (unreadClueCount) {
// console.log('unreadClueCount: ', unreadClueCount);
if(unreadClueCount>0){
return true
}else{
return false;
}
};
module.exports = {
hasRedpoint: hasRedpoint,
};
/* components/Tab/Tab.wxss */
@import "../../common.wxss";
.tab-box {
display: flex;
/* display: grid; */
width: 100%;
height: 92rpx;
box-sizing: border-box;
}
.tab-box.left{
.tab-box.left {
padding-left: 32rpx;
}
.left .tab{
padding-right:40rpx;
.left .tab {
padding-right: 40rpx;
}
.flex .tab {
/* .flex .tab {
flex: 1;
}
} */
.tab {
position: relative;
flex-shrink: 0;
}
.tab .text {
height: 84rpx;
display: flex;
......@@ -27,19 +32,24 @@
box-sizing: border-box;
color: #A9A9A9;
justify-content: center;
font-size: 28rpx;
}
.left .text{
.left .text {
justify-content: flex-start;
}
.flex .tab .text {
padding: 0;
}
.tab.active .text {
font-weight: 500;
font-size: 28rpx;
/* font-weight: 500; */
font-weight: 600;
font-size: 44rpx;
transition: all .25s;
color: #2C2C2C;
font-family: PingFangSC-S0pxibold;
}
.tab .line {
......@@ -61,4 +71,39 @@
width: 0;
height: 0;
color: transparent;
}
.active .redpoint {
display: none;
}
.redpoint {
position: absolute;
top: 10px;
right: 5px;
/* top: 8px;
right: 10px; */
width: 10px;
height: 10px;
background: #EB4E4E;
border-radius: 50%;
}
/* 外部出进来的自定义样式 */
.project-tab {
padding-left: 20px;
padding-right: 20px;
}
.project-tab .tab {
margin-right: 28px;
}
.project-tab .tab.active .text {
font-size: 28rpx;
color: var(--btnColor);
}
.project-tab .tab .line {
width: auto;
}
\ No newline at end of file
/**
* 用来配置小程序项目的变量
* 统一管理
*/
// 配置预发布的小程序aapId
export const preReleaseAppId = 'wx24ebae5768e74138'
// sentry Dsn 地址
export const dsnUrl = 'https://59c3cfc3ffb84ed68fc0dda26fb09e12@sentry.glsx.com.cn/30'

1.42 KB | W: | H:

2.64 KB | W: | H:

images/home.png
images/home.png
images/home.png
images/home.png
  • 2-up
  • Swipe
  • Onion skin

1.63 KB | W: | H:

2.88 KB | W: | H:

images/home_active.png
images/home_active.png
images/home_active.png
images/home_active.png
  • 2-up
  • Swipe
  • Onion skin

1.34 KB | W: | H:

2.59 KB | W: | H:

images/mine.png
images/mine.png
images/mine.png
images/mine.png
  • 2-up
  • Swipe
  • Onion skin

1.47 KB | W: | H:

2.84 KB | W: | H:

images/mine_active.png
images/mine_active.png
images/mine_active.png
images/mine_active.png
  • 2-up
  • Swipe
  • Onion skin
// pages/accountItems/accountItems.js
import USERAPI from '~/api/usersApi/index'
import {
selectAccountLogin
} from '~/login/lib/index'
const navStyle = 'background-color: rgba(0,0,0,0)'
Page({
/**
* 页面的初始数据
*/
data: {
navStyle
},
onRoute({
sessionId
}) {
this.getListSelectAccount(sessionId)
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
onPageScroll({
scrollTop
}) {
let scrollTop_num = scrollTop / 100
if (scrollTop_num > 0 && scrollTop_num <= 1 && this.data.navStyle != 'background-color:#FFF;') this.setData({
navStyle: `background-color:#FFF;`
})
if (scrollTop_num == 0) this.setData({
navStyle
})
},
getListSelectAccount(sessionId) {
wx.$api.showLoading('加载中...')
USERAPI.getAccountList(sessionId).then(({
code,
data,
message
}) => {
wx.hideLoading()
if (code == 0) {
let {
loginUserInfoList,
sessionId
} = data
this.setData({
loginUserInfoList
})
this.sessionId = sessionId
} else wx.$api.showToast(message)
this.setData({
flag: true
})
})
},
chooseAccount(e) {
let {
index
} = e.currentTarget.dataset
let {
loginUserInfoList
} = this.data
if (loginUserInfoList[index].active) return
loginUserInfoList.map(i => (i.active = false))
loginUserInfoList[index].active = true
this.setData({
loginUserInfoList
})
},
choiceAccountLogin() {
let {
loginUserInfoList
} = this.data,
id = null, {
sessionId
} = this
loginUserInfoList.map(e => {
if (e.active) id = e.uuid
})
if (!id) {
wx.$api.showToast('请选择账号')
return
}
console.log(sessionId)
wx.$api.showLoading()
selectAccountLogin({
id,
sessionId
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {},
})
\ No newline at end of file
{
"usingComponents": {
"navigation-bar": "/components/NavigationBar/NavigationBar"
},
"navigationStyle": "custom"
}
\ No newline at end of file
/* login/accountItems/accountItems.wxss */
@import '../index/index.scss';
page {
background-color: #fff;
}
.layout {
font-size: 28rpx;
color: #323436;
letter-spacing: 0;
padding: 196rpx 32rpx 224rpx;
position: relative;
&::after {
content: '';
width: 100%;
height: 486rpx;
background: url('https://img02.glsx.com.cn/weapp/resource/saas/business-assistant/login/bg.webp') no-repeat;
background-size: 100% 486rpx;
position: absolute;
left: 0;
top: 0;
z-index: -1;
}
}
.title {
font-weight: 500;
font-size: 36rpx;
color: #323436;
margin-bottom: 20rpx;
}
.items {
width: 100%;
min-height: 108rpx;
box-shadow: 0 4rpx 16rpx 0 rgba(180, 186, 204, 0.32);
padding: 32rpx;
margin-bottom: 32rpx;
background-color: #fff;
display: flex;
align-items: center;
justify-content: space-between;
box-sizing: border-box;
}
.items .name {
width: calc(100% - 70rpx);
}
.items:last-of-type {
margin-bottom: 0;
}
.radio {
width: 28rpx;
height: 28rpx;
border: 2rpx solid #DDE3F0;
border-radius: 100%;
transition: all .2s;
box-sizing: border-box;
}
.icon {
width: 28rpx;
height: 28rpx;
transition: all .2s;
display: none;
}
.active .icon {
display: block;
}
.active .radio {
display: none;
}
.btn-box {
position: fixed;
left: 0;
bottom: 0;
width: 100%;
height: 140rpx;
display: flex;
justify-content: center;
align-items: center;
z-index: 20;
background-color: #fff;
color: #fff;
padding: 0 32rpx;
box-sizing: border-box;
}
.list-not {
height: calc(100vh - 159px);
font-size: 40rpx;
}
\ No newline at end of file
<view class="layout">
<navigation-bar navStyle="{{navStyle}}">选择账号</navigation-bar>
<view class="title">请选择登录的账号</view>
<view class="list">
<block wx:if="{{flag}}">
<block wx:if="{{loginUserInfoList.length}}">
<block wx:for="{{loginUserInfoList}}" wx:key="index">
<view class="items {{item.active?'active':''}}" bindtap="chooseAccount" data-index="{{index}}">
<view class="name">
{{item.merchantName}}{{item.isSuper?'(超管)':item.userType==1?'(商户号)':'(员工号)'}}
</view>
<view class="icon">
<image src="{{IMG_URL}}login/radio.png" />
</view>
<view class='radio' />
</view>
</block>
</block>
<block wx:else>
<view class="list-not text-center" bindtap="getListSelectAccount">
点击刷新
</view>
</block>
</block>
</view>
<view class="btn-box isFullSucreen">
<button class="button" disabled="{{!loginUserInfoList.length}}" bindtap="choiceAccountLogin">确定</button>
</view>
</view>
\ No newline at end of file
// login/index/components/Agree/Agree.js
import { imgUrlMixin } from '~/mixins/index'
Component({
behaviors: [imgUrlMixin],
options: {
styleIsolation: 'shared'
},
/**
* 组件的属性列表
*/
properties: {
show: Boolean,
text: String,
value: {
type: Boolean,
value: false,
observer(n) {
this.setData({
agree: n
})
}
}
},
/**
* 组件的初始数据
*/
data: {
agree: false
},
/**
* 组件的方法列表
*/
methods: {
agree() {
let {agree} = this.data
this.triggerEvent('change', !agree)
},
}
})
\ No newline at end of file
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file
/* login/index/components/Protocol/Protocol.wxss */
.protocol {
margin-top: 274rpx;
/* login/index/components/Agree/Agree.wxss */
.agree {
// position: fixed;
// left: 0;
// bottom: 100rpx;
width: 100%;
margin-top: 20rpx;
text {
color: #5092FF;
}
......
<block wx:if="{{show}}">
<view class="agree text-center" bindtap="agree">
<view class="icon {{agree}}">
<image webp src="{{IMGURL}}login/radio.png"></image>
</view>
<block wx:if="{{text}}">{{text}}</block>
<block wx:else>
<slot></slot>
</block>
</view>
</block>
\ No newline at end of file
// login/index/components/LoginBox.js
import USERAPI from '~/api/usersApi/index'
import {
checkLoginUserInfo,
setLoginInfo,
loginModal
} from '~/login/lib/index'
import md5 from '~/utils/lib/md5'
import network from '~/utils/network'
import {
imgUrlMixin
} from '~/mixins/index'
let thisPage
Component({
behaviors: [imgUrlMixin],
options: {
styleIsolation: 'shared'
},
/**
* 组件的属性列表
*/
properties: {
loginType: Number
loginType: Number,
disabled: Boolean
},
/**
* 组件的初始数据
*/
data: {
formData: {
phone: '',
code: '',
account: '',
password: ''
},
phoneReady: false,
countDown: null
},
/**
* 组件的方法列表
*/
methods: {
/**隐藏验证码错误 */
hideError(name) {
if (name == 'code')
this.setData({
smsError: false
})
},
/**输入回调 */
input(e) {
const {
value
} = e.detail, {
name
} = e.currentTarget.dataset
this.setData({
[`formData.${name}`]: value
})
if (name == 'phone')
this.setData({
phoneReady: thisPage.validate.methods.tel(value)
})
this.hideError(name)
this.checkFormData()
},
/**清除input value */
clear(e) {
const {
name
} = e.currentTarget.dataset
this.setData({
[`formData.${name}`]: ''
})
this.hideError(name)
this.checkFormData()
},
/**获取验证码 */
getSmsCode() {
const {
phoneReady,
formData,
count
} = this.data,
countDown = 60
if (!phoneReady || count) return
this.setData({
smsLoading: true
})
USERAPI.getSmsCode(formData.phone)
.then(({
code,
message
}) => {
this.setData({
smsLoading: false
})
if (code == '0') this.countDown(countDown)
else wx.$api.showToast(message || '发送验证码失败')
})
.catch(err => {
this.setData({
smsLoading: false
})
wx.$api.showToast(err || '发送验证码失败')
})
},
/**验证码倒计时 */
countDown(countDown) {
if (countDown)
this.setData({
count: countDown
})
setTimeout(() => {
let {
count
} = this.data
this.setData({
count: --count
})
if (count > 0) this.countDown()
else
this.setData({
count: null
})
}, 1e3)
},
/**检查输入框内容 */
checkFormData() {
const {
loginType,
formData
} = this.data
if (loginType != 0) {
if (loginType == 1) {
this.setData({
phoneReady: formData.phone && thisPage.validate.methods.tel(formData.phone)
},
() => {
thisPage.checkLoginBtn()
}
)
} else thisPage.checkLoginBtn()
}
},
/**显示隐藏密码 */
pwdSwitch() {
this.setData({
showPwd: !this.data.showPwd
})
},
/**手机号&帐号密码登录 */
login() {
const {
formData,
loginType
} = this.data,
target = {
1: 'phoneSmsLogin',
2: 'accountLogin'
} [loginType],
obj =
loginType == 1 ? {
mobile: formData.phone,
code: formData.code
} : {
userName: formData.account,
password: md5(formData.password)
}
this.setBtnLoading()
USERAPI[target](obj)
.then(({
code,
data,
message
}) => {
this.setBtnLoading(false)
if (code == '0') {
if (loginType == 1) checkLoginUserInfo(data)
else {
const {
autoLogin
} = thisPage.data, {
sessionId,
loginUserInfoList
} = data,
validTime = 3600 * 24 * 7 * 1e3,
autoLoginFailureTime = Date.now() + validTime
if (autoLogin && loginUserInfoList[0]) {
wx.$storage.set('auto_login_object', {
failureTime: autoLoginFailureTime,
userName: formData.account,
password: md5(formData.password)
})
} else wx.$storage.rm('auto_login_object')
setLoginInfo(loginUserInfoList[0], sessionId)
}
} else {
if (loginType == 1)
this.setData({
smsError: true
})
wx.$api.showToast(message || '系统异常')
}
})
.catch(err => {
wx.$api.showToast('系统异常')
this.setBtnLoading(false)
})
},
/**微信登录 */
wxLogin({
detail
}) {
if (!detail.code) return
this.setBtnLoading()
USERAPI.authUserPhone(detail, this.loginToken)
.then(({
code,
data,
message
}) => {
if (code == '0') checkLoginUserInfo(data)
else {
wx.$api.showToast(message || '系统异常')
this.init()
}
this.setBtnLoading(false)
})
.catch(({
errMsg
}) => {
wx.$api.showToast(errMsg || '系统异常')
this.setBtnLoading(false)
this.init()
})
},
/**设置登录按钮loading状态 */
setBtnLoading(loading = true) {
thisPage.setData({
loading
})
this.setData({
loading
})
},
/**页面初始化 */
async init() {
network.getNetworkType()
thisPage = wx.$router.getPageInstance()
try {
const {
data,
code,
message
} = await USERAPI.wxCodeLogin()
if (code == '0') {
thisPage.setData({
disabled: false
})
this.loginToken = data
} else this.reLogin(message)
wx.hideLoading()
} catch ({
errMsg
}) {
console.error(errMsg)
this.reLogin()
}
},
/**获取loginToken */
async reLogin(message) {
const reload = await loginModal({
message: message || '获取loginToken失败'
})
if (reload) this.init()
}
}
})
\ No newline at end of file
{
"component": true,
"usingComponents": {}
"usingComponents": {
"input-icon":"../InputIcon/InputIcon"
}
}
\ No newline at end of file
/* login/index/components/LoginBox.wxss */
.box {
height: 800rpx;
// height: 800rpx;
height: 750rpx;
.opacity-view {
animation: opacity-view .5s forwards;
}
.img {
width: 472rpx;
height: 458rpx;
position: absolute;
left: 151rpx;
top: 264rpx;
// top: 264rpx;
top: 214rpx;
}
.input-box {
width: 540rpx;
// padding-top: 352rpx;
padding-top: 302rpx;
margin: 0 auto;
.title {
font-weight: 500;
font-size: 44rpx;
color: #323436;
}
.input {
display: flex;
align-items: center;
margin-top: 33rpx;
border-bottom: 1rpx solid #E3E3E6;
padding: 24rpx 0;
position: relative;
input {
flex: 1;
color: #323436;
font-size: 28rpx;
}
.placeholder {
color: #CCCED1;
font-size: 28rpx;
}
.sms {
width: 160rpx;
flex-shrink: 0;
color: #5092FF;
font-size: 24rpx;
padding: 0;
text-align: right;
transition: all .25s;
&[disabled]:not([type]) {
color: #CCCED1;
}
}
.error {
position: absolute;
font-size: 24rpx;
color: #F35251;
left: 0;
bottom: -13rpx;
transform: translateY(100%);
}
}
}
}
\ No newline at end of file
<view class="box">
<block wx:if="{{loginType == 0}}">
<image webp class="img" src="https://img02.glsx.com.cn/weapp/resource/saas/business-assistant/login/login.png" />
<image webp class="img opacity-view" src="{{IMGURL}}login/login.webp" />
</block>
<block wx:else>
<view class="input-box opacity-view">
<view class="title">{{loginType == 1?'手机号':'账号'}}登录</view>
<block wx:if="{{loginType == 1}}">
<view class="input">
<input type="number" placeholder="填写手机号" placeholder-class="placeholder" bindinput="input" data-name="phone" value="{{formData.phone}}" maxlength="11" />
<input-icon show="{{formData.phone}}" bindtap="clear" data-name="phone" />
</view>
<view class="input">
<input type="number" placeholder="填写验证码" placeholder-class="placeholder" bindinput="input" data-name="code" value="{{formData.code}}" maxlength="4" />
<input-icon show="{{formData.code}}" bindtap="clear" data-name="code" />
<button class="sms text-center " bindtap="getSmsCode" disabled="{{count || !phoneReady}}" loading="{{smsLoading}}">{{
count? count + 's':'获取验证码'
}}</button>
<block wx:if="{{smsError}}">
<view class="error">验证码错误</view>
</block>
</view>
</block>
<block wx:else>
<view class="input">
<input type="text" placeholder="填写账号" placeholder-class="placeholder" bindinput="input" data-name="account" value="{{formData.account}}" maxlength="15" />
<input-icon show="{{formData.account}}" bindtap="clear" data-name="account" />
</view>
<view class="input">
<input type="text" placeholder="填写密码" placeholder-class="placeholder" bindinput="input" data-name="password" value="{{formData.password}}" maxlength="20" password='{{!showPwd}}' />
<input-icon show bindtap="pwdSwitch" type="{{showPwd?'showPwd':'hidePwd'}}" />
<input-icon show="{{formData.password}}" bindtap="clear" data-name="password" />
</view>
</block>
</view>
</block>
</view>
\ No newline at end of file
</view>
<block wx:if="{{loginType == 0}}">
<button class="button" disabled="{{disabled}}" hover-class="btn-hover" open-type="getPhoneNumber" bindgetphonenumber="wxLogin" loading="{{loading}}">微信登录</button>
</block>
<block wx:else>
<button class="button" disabled="{{disabled}}" hover-class="btn-hover" bindtap="login" loading="{{loading}}">登录</button>
</block>
\ No newline at end of file
// login/index/components/InputIcon/InputIcon.js
Component({
/**
* 组件的属性列表
*/
properties: {
show: Boolean,
type: {
type: String,
value: 'clear'
},
src: String
},
/**
* 组件的初始数据
*/
data: {
ICON_TYPE: {
showPwd: './images/seePwd.png',
hidePwd: './images/hidePwd.png',
clear: './images/clear.png'
}
},
/**
* 组件的方法列表
*/
methods: {
}
})
\ No newline at end of file
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file
/* login/index/components/Clear/Clear.wxss */
.icon-box {
width: 44rpx;
height: 40rpx;
padding: 0 10rpx;
flex-shrink: 0;
display: flex;
align-items: center;
justify-content: center;
transition: all .25s;
.icon {
width: 32rpx;
height: 32rpx;
}
}
\ No newline at end of file
<view class="icon-box" hidden="{{!show}}">
<image src="{{src || ICON_TYPE[type]}}" class="icon"></image>
</view>
\ No newline at end of file
// login/index/components/Protocol/Protocol.js
// login/index/components/Mask/Mask.js
Component({
options: {
styleIsolation: 'shared'
},
/**
* 组件的属性列表
*/
properties: {
agree:Boolean
maskStyle: String,
show: Boolean
},
/**
* 组件的初始数据
*/
data: {
},
/**
* 组件的方法列表
*/
methods: {
agreeProtocol() {
const thisPage = wx.$router.getPageInstance(),
{agree} = thisPage.data
thisPage.setData({
agree: !agree
})
thisPage.checkLoginBtn()
},
}
})
})
\ No newline at end of file
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file
/* login/index/components/Mask/Mask.wxss */
.mask{
position: fixed;
top: 0;
left: 0;
bottom: 0;
right: 0;
z-index: 99999999999;
}
\ No newline at end of file
<block wx:if="{{show}}">
<view class="mask" style="{{maskStyle}}"></view>
</block>
\ No newline at end of file
<view class="protocol text-center">
<view class="icon {{agree}}" bindtap="agreeProtocol">
<image src="https://img02.glsx.com.cn/weapp/resource/saas/business-assistant/login/radio.png"></image>
</view>
我已阅读并同意<text>《隐私权政策》</text>
</view>
\ No newline at end of file
// login/index/components/TypeList.js
import { imgUrlMixin } from '~/mixins/index'
Component({
behaviors: [imgUrlMixin],
/**
* 组件的属性列表
*/
......@@ -24,6 +26,7 @@ Component({
thisPage.setData({
loginType
})
wx.vibrateShort()
thisPage.checkLoginBtn()
},
}
......
/* login/index/components/TypeList.wxss */
.tips {
padding-top: 120rpx;
padding-top: 100rpx;
text-align: center;
margin-bottom: 40rpx;
}
.tips.true{
padding-top: 48rpx;
}
.login-list {
display: flex;
align-items: center;
justify-content: center;
gap: 0 118rpx;
.item {
display: flex;
align-items: center;
flex-direction: column;
width: 100rpx;
animation: opacity-view .25s forwards;
animation: btn-move .25s forwards;
margin:0 59rpx;
.icon {
width: 68rpx;
height: 68rpx;
......@@ -25,5 +26,13 @@
}
}
@keyframes btn-move {
0% {
transform: scale(0.1);
}
100% {
transform: scale(1);
}
}
}
\ No newline at end of file
<view class="tips">其他方式</view>
<view class="tips {{loginType == 2}}">其他方式</view>
<view class="login-list">
<block wx:for="{{loginList}}" wx:key="index">
<block wx:if="{{loginType != index}}">
<view class="item" bindtap="changLoginType" data-index="{{index}}">
<image class="icon" src="https://img02.glsx.com.cn/weapp/resource/saas/business-assistant/login/icon-{{index}}.png"></image>
<image class="icon" webp src="{{IMGURL}}login/icon-{{index}}.png"></image>
{{item}}
</view>
</block>
......
// pages/login/index/index.js
import WxValidate from '../../utils/WxValidate.js'
Page({
/**
* 页面的初始数据
*/
data: {
navStyle: 'background-color: rgba(0,0,0,0);',
/**0:微信 1:手机号 2:账号密码 */
loginType: 0,
agree: true
/**按钮disabled */
disabled: true,
/**免登 */
autoLogin: false
},
onRoute(options) {},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
this.validate = new WxValidate()
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
onReady() {},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
wx.$util.showLoading()
onShow(options, refresh) {
1
if (refresh) {
this.setData({
disabled: true
})
}
wx.hideHomeButton({
success: (res) => {
success: res => {
wx.hideLoading()
const login = this.selectComponent('#box')
if (login) login.init()
// this.checkLoginBtn()
}
})
},
......@@ -39,44 +47,44 @@ Page({
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
onHide() {},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
onUnload() {},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
onPullDownRefresh() {},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
onReachBottom() {},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
// onShareAppMessage() {},
/**30天免登 */
changeAgree(e) {
this.setData({
autoLogin: e.detail
})
},
checkLoginBtn() {
const {
agree,
loginType
} = this.data
checkLoginBtn(disabled = false) {
const { loginType } = this.data,
{
data: { formData },
loginToken
} = this.selectComponent('#box')
if (loginType == 0) {
disabled = loginToken
} else disabled = loginType == 1 ? formData.phone && this.validate.methods.tel(formData.phone) && formData.code && formData.code.length == 4 : formData.account && formData.password
this.setData({
disabled: !agree
disabled: !disabled
})
}
})
\ No newline at end of file
})
{
"usingComponents": {
"navigation-bar": "/components/NavigationBar/NavigationBar",
"mask": "./components/Mask/Mask",
"box": "./components/Box/Box",
"type-list": "./components/TypeList/TypeList",
"protocol": "./components/Protocol/Protocol"
"agree": "./components/Agree/Agree"
},
"navigationStyle": "custom"
"navigationStyle": "custom",
"disableScroll": true
}
\ No newline at end of file
@keyframes opacity-view {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
.layout {
position: relative;
padding: 0 32rpx;
......@@ -18,29 +8,41 @@
content: '';
width: 100%;
height: 486rpx;
background: url('https://img02.glsx.com.cn/weapp/resource/saas/business-assistant/login/bg.png') no-repeat;
background: url('https://img02.glsx.com.cn/weapp/resource/saas/business-assistant/login/bg.webp') no-repeat;
background-size: 100% 486rpx;
position: absolute;
left: 0;
top: 0;
z-index: -1;
}
.button {
width: 100%;
height: 88rpx;
background: #3666FE;
border-radius: 8rpx;
font-weight: 500;
font-size: 28rpx;
color: #FFFFFF;
line-height: 88rpx;
padding: 0;
}
@keyframes opacity-view {
0% {
opacity: 0;
transform: scale(0.1);
}
.disabled{
background: #CCCED1;
100% {
opacity: 1;
transform: scale(1);
}
.btn-hover {
opacity: .75;
}
.button {
width: 100% !important;
height: 88rpx;
background: var(--btnColor);
border-radius: 8rpx;
font-weight: 500;
font-size: 28rpx;
color: #FFFFFF;
line-height: 88rpx;
padding: 0;
transition: all .1s;
&[disabled]:not([type]){
background: #CCCED1 !important;
color: #fff !important;
}
}
.btn-hover {
opacity: .75;
}
\ No newline at end of file
<navigation-bar navStyle="{{navStyle}}">生意助手</navigation-bar>
<view class="layout">
<box loginType="{{loginType}}" />
<button class="button {{disabled?'disabled':''}}" hover-class="btn-hover">{{loginType == 0?'微信登陆':'登陆'}}</button>
<mask show="{{loading}}"></mask>
<navigation-bar navStyle="background-color: rgba(0,0,0,0)">生意助手</navigation-bar>
<box loginType="{{loginType}}" disabled="{{disabled}}" id="box" />
<agree show="{{loginType == 2}}" text="7天内免登陆" value="{{autoLogin}}" bindchange="changeAgree" />
<type-list loginType="{{loginType}}" />
<protocol agree="{{agree}}" />
</view>
\ No newline at end of file
import {
setSessionId,
setUserInfo
} from '~/utils/cache/storageApi'
import USERAPI from '~/api/usersApi/index'
const setRouteData = targetPath => {
let [url, query] = targetPath.split('?'),
obj = {}
if (query) {
const [key, val] = query.split('=')
obj = {
[key]: val
}
}
return {
url,
obj
}
}
/**选择账号登录 */
const selectAccountLogin = ({
id,
sessionId
}) => {
USERAPI.selectAccountLogin({
id,
sessionId
}).then(({
code,
data,
message
}) => {
if (code == '0') {
console.log(data)
setLoginInfo(data.loginUserInfoList[0], data.sessionId)
} else wx.$api.showToast(message || '系统异常')
})
}
/**设置登录信息 */
const setLoginInfo = (userInfo, sessionId) => {
if (!userInfo) {
wx.$api.showToast('仅支持服务商类型账户登录')
return
}
setUserInfo(userInfo)
setSessionId(sessionId)
loginSuccess()
}
/**成功跳转 */
const loginSuccess = () => {
const {
options: {
targetPath
}
} = wx.$router.getPageInstance()
if (targetPath) {
const {
url,
obj
} = setRouteData(targetPath)
wx.$router.reLaunch(url, obj)
} else wx.$router.go('pages.index')
}
const loginModal = async ({
message,
confirmText,
cancelText
}) => {
return new Promise((resolve, reject) => {
wx.showModal({
content: message || '网络异常',
confirmText: confirmText || '重试',
cancelText: cancelText || '取消',
confirmColor: '#3666FE',
success(res) {
if (res.confirm) resolve(res.confirm)
if (res.cancel) reject(false)
}
})
})
}
/**手机号&微信登录:是否跳转登录列表页 */
const checkLoginUserInfo = ({
loginUserInfoList,
sessionId
}) => {
const thisPage = wx.$router.getPageInstance()
/**多个账号 */
if (loginUserInfoList.length > 1)
wx.$router.go('login.accountItems', {
sessionId,
...thisPage.options
})
/**只有一个账号 */
else
selectAccountLogin({
id: loginUserInfoList[0].uuid,
sessionId
})
}
module.exports = {
checkLoginUserInfo,
selectAccountLogin,
loginSuccess,
setRouteData,
setLoginInfo,
loginModal
}
\ No newline at end of file
import {
checkLoginUserInfo,
setRouteData,
setLoginInfo,
loginModal
} from '../lib/index'
import {
getSessionId,
} from '~/utils/cache/storageApi'
import USERAPI from '~/api/usersApi/index'
Page({
/**
......@@ -25,19 +36,16 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow() {
const {
sessionId,
} = wx.$storage.get(), {
url,
path = decodeURIComponent(url)
} = this.options
console.log(path)
if (sessionId) {
} else {
wx.$router.reLaunch('login.index')
}
const appEnter = wx.getEnterOptionsSync()
if (appEnter.scene == 1037) {
if (Object.keys(appEnter.referrerInfo).length) {
const {
extraData
} = appEnter.referrerInfo
if (extraData && Object.keys(extraData).length) this.phoneSmsLogin(extraData)
else this.init()
} else this.init()
} else this.init()
},
/**
......@@ -67,11 +75,93 @@ Page({
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
init() {
wx.nextTick(() => {
const sessionId = getSessionId(),
{
url,
targetPath = url ? decodeURIComponent(url) : ''
} = this.options
let path = 'pages.index',
obj = {}
if (targetPath) obj.targetPath = targetPath
if (sessionId) {
USERAPI.checkSession().then(({
code
}) => {
if (code == '0') {
if (targetPath) {
path = setRouteData(targetPath).url
obj = setRouteData(targetPath).obj
}
wx.$router.reLaunch(path, obj)
} else this.autoLogin(obj)
})
} else this.autoLogin(obj)
})
},
autoLogin(obj) {
const autoLoginObject = wx.$storage.get('auto_login_object')
if (autoLoginObject) {
const {
failureTime,
userName,
password
} = autoLoginObject
if (Date.now() < failureTime) {
USERAPI.accountLogin({
userName,
password
}).then(async ({
data,
code,
message
}) => {
if (code == '0' && data.loginUserInfoList.length) {
const {
sessionId,
loginUserInfoList
} = data
setLoginInfo(loginUserInfoList[0], sessionId)
} else {
try {
const reload = await loginModal({
message: data.loginUserInfoList.length ? message : '登录失败请重试',
cancelText: '返回'
})
if (reload) this.onShow()
} catch (error) {
wx.$storage.rm('auto_login_object')
wx.$router.reLaunch('login.index', obj)
}
}
})
} else wx.$router.reLaunch('login.index', obj)
} else wx.$router.reLaunch('login.index', obj)
},
phoneSmsLogin(extraData) {
console.log(extraData)
USERAPI.phoneSmsLogin({
mobile: extraData.phone,
code: extraData.smscode
}).then(({
code,
data,
message
}) => {
if (code == '0') checkLoginUserInfo(data)
else {
wx.$api.showToast(message || '系统异常')
setTimeout(() => {
wx.$router.reLaunch('login.index')
}, 1e3)
}
})
.catch(err => {
wx.$api.showToast('系统异常')
setTimeout(() => {
wx.$router.reLaunch('login.index')
}, 1e3)
})
}
})
\ No newline at end of file
{
"usingComponents": {}
"usingComponents": {},
"navigationStyle": "custom",
"disableScroll": true
}
\ No newline at end of file
.layout{
.layout {
width: 100vw;
height: 100vh;
display: grid;
place-items: center;
.icon{
width: 480rpx;
height: 480rpx;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
background-color: #fff;
.loading {
height: 48rpx;
view {
width: 16rpx;
height: 100%;
display: inline-block;
background-color: #0052d9;
animation: stretchdelay 1.2s infinite ease-in-out;
margin: 0 4rpx;
&:nth-child(2) {
animation-delay: -1.1s;
}
&:nth-child(3) {
animation-delay: -1s;
}
&:nth-child(4) {
animation-delay: -.9s;
}
}
}
}
@keyframes stretchdelay {
0%,
100%,
40% {
transform: scaley(.33);
}
20% {
transform: scaley(1);
}
}
\ No newline at end of file
<view class="layout">
<image class="icon" src="https://img02.glsx.com.cn/weapp/resource/scrm-mobile/crowdfunding/COVER_LIVE.gif"></image>
<image webp src="{{IMG_URL}}login/index-loading.webp" mode="widthFix" ></image>
<!-- <view class="loading">
<block wx:for="{{4}}" wx:key="index">
<view></view>
</block>
</view> -->
</view>
\ No newline at end of file
No preview for this file type
This diff is collapsed. Click to expand it.
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!