Browse Source

no message

feature/v1.0
xpz2018 5 years ago
parent
commit
0dcf7b4b22
31 changed files with 225 additions and 679 deletions
  1. 8
      app.js
  2. 2
      app.json
  3. BIN
      assets/image/bg-logo.png
  4. BIN
      assets/image/icon_logo.png
  5. 20
      pages/api/payment.js
  6. 18
      pages/api/saas.js
  7. 99
      pages/api/user.js
  8. 1
      pages/home/index/index.js
  9. 18
      pages/home/index/index.wxml
  10. 171
      pages/index/index.js
  11. 3
      pages/index/index.json
  12. 4
      pages/index/index.wxml
  13. 263
      pages/login/index.js
  14. 3
      pages/login/index.json
  15. 121
      pages/login/index.wxml
  16. 13
      pages/login/index.wxss
  17. 23
      pages/mall/components/cell/index.js
  18. 4
      pages/mall/components/cell/index.json
  19. 2
      pages/mall/components/cell/index.wxml
  20. 1
      pages/mall/components/cell/index.wxss
  21. 23
      pages/mall/components/fence/index.js
  22. 4
      pages/mall/components/fence/index.json
  23. 2
      pages/mall/components/fence/index.wxml
  24. 1
      pages/mall/components/fence/index.wxss
  25. 23
      pages/mall/components/sku/index.js
  26. 4
      pages/mall/components/sku/index.json
  27. 2
      pages/mall/components/sku/index.wxml
  28. 1
      pages/mall/components/sku/index.wxss
  29. 10
      pages/process/index/index.json
  30. 58
      pages/process/index/index.wxml
  31. 2
      project.config.json

8
app.js

@ -1,15 +1,15 @@
//app.js
App({
//----------------------------------------------globalData--------------------------------------
release: 1,
release: 0,
tmplIds: ['kg0T1ve0FpYrEtZ4ExbypHm8mtS7OJaehvqN_T9ypoI'],
version: 152,
xAppId: '503258978847952896',
accountInfo: null,
xAppId: '503258978847953926',
userInfo: null,
globalData: {
openId: null,
token: null,
isIPhoneX: false,
keyboardHeight: 0,
isIos: false
}
})

2
app.json

@ -1,7 +1,7 @@
{
"pages":[
"pages/index/index",
"pages/login/index",
"pages/index/index",
"pages/home/mobile/index",
"pages/home/authory/index",
"pages/htmls/agreement/index",

BIN
assets/image/bg-logo.png

Before After
Width: 375  |  Height: 738  |  Size: 36 KiB

BIN
assets/image/icon_logo.png

Before After
Width: 91  |  Height: 102  |  Size: 2.6 KiB Width: 100  |  Height: 100  |  Size: 5.8 KiB

20
pages/api/payment.js

@ -1,20 +0,0 @@
/**
* Copyright © 2020-present LiuDanYang. All rights Reserved.
*/
import { mGet, mPost } from "./request"
const app = getApp()
const pconfig = {
baseUrl: app.release ? `https://psc.qniao.cn` : `http://psc-dev.qniao.cn`
}
// *******************************************************************账户业务***********************************************************
// /credit/get/self-enterprise-credit-by-enterprise-id查看个人的采购额度
const getCreditInfo = (params) => mGet(`/payment-settlement-center/credit/get/self-enterprise-credit-by-enterprise-id`, params, pconfig)
const paymentInfo = (params) => mPost(`/payment-settlement-center/pay`, params, pconfig)
export {
pconfig,
getCreditInfo,
paymentInfo
}

18
pages/api/saas.js

@ -0,0 +1,18 @@
/**
* Copyright © 2020-present LiuDanYang. All rights Reserved.
*/
import { mGet, mPost } from "./request"
const app = getApp()
const sconfig = {
baseUrl: app.release ? `https://api-client-ztb.qniao.cn` : `http://47.113.118.47:9000`
}
// *****************************************账户业务**********************************************
const loginToken = (params) => mPost(`/recycle-user-center/authorize/get/product-line-token/by/login-token`, params, sconfig)
const getBaseInfo = () => mGet(`/ztb-factory/get/self-enterprise-profile-detail`, null, sconfig)
export {
sconfig,
loginToken,
getBaseInfo
}

99
pages/api/user.js

@ -1,59 +1,24 @@
/**
* Copyright © 2020-present LiuDanYang. All rights Reserved.
*/
import { mGet, mPost, mDelete } from "./request"
// import { mconfig } from "./mall"
// import { cconfig } from "./cloud"
import { pconfig } from "./payment"
import { mGet, mPost } from "./request"
import { sconfig } from "./saas"
const util = require('../../utils/util')
const storage = require('../../utils/storage')
const app = getApp()
const config = {
baseUrl: app.release ? 'https://uec.qniao.cn' : 'http://47.107.97.166:9000',
header: {
'Authorization': `QNT ` + storage.get('Authorization')
}
baseUrl: app.release ? 'https://uec.qniao.cn' : 'https://uec-dev.qniao.cn'
}
const checkTestCode = (params) => mGet(`/uec/get/check/qr-code`, params, config)
///uec/get/auth-captcha
const verifyCode = (code, params) => mGet(`/uec/verify/qrcode${code}`, params, config)
const qrcodeEmploye = (params) => mPost(`/uec/generate/qrcode`, params, config)
// /uec/get/wechat-applet-session
const wechatApplet = (params) => mPost('/uec/get/wechat-applet-session', params, config)
const authCaptcha = (params) => mPost(`/uec/get/auth-captcha`, params, config)
const verifyCaptcha = (params) => mPost(`/uec/authorize/by-captcha`, params, config)
const loginCaptcha = (params) => mPost(`/uec/authorize/by-captcha`, params, config)
const loginPwd = (params) => mPost(`/uec/authorize/by-password`, params, config)
const postCaptcha = (params) => mPost(`/uec/get/auth-captcha`, params, config)
const setPassword = (params) => mPost(`/uec/user/set/sign-in-password`, params, config)
const modifyMobile = (params) => mPost(`/uec/user/modify/mobile`, params, config)
const getUserInfo = (params) => mGet('/uec/get/user-info', params, config)
const getAuthSession = () => mGet('/uec/create/identity-auth-session', null, config)
const certificateImage = (params) => mPost('/uec/recognize/certificate-img', params, config)
const certificateIdentity = (params) => mPost('/uec/identify/identity', params, config)
const bindingAdmin = (params) => mPost(`/uec/bind/primary-account`, params, config)
const bindingAccount = (params) => mPost(`/uec/apply/to/be/emplyee/of/enterprise`, params, config)
const getCheckList = (params) => mGet(`/uec/get/auditing-joining-enterprise-application-list`, params, config)
const getEmployeList = (params) => mGet(`/uec/get/passed-employees`, params, config)
const auditEmploye = (params) => mPost(`/uec/audit/employee-joining-application`, params, config)
const deleteEmploye = (params) => mPost(`/uec/remove/employees`, params, config)
const adminEmploye = (params) => mPost(`/uec/grant/admin-role/to/employees`, params, config)
const getAddressList = () => mGet(`/uec/get/enterprise-shipping-address-list/by-userId`, null, config)
const getAddressInfo = (id) => mGet(`/uec/get/enterprise-shipping-address-list/by-userId`, null, config)
const saveAddress = (params) => mPost(`/uec/save/enterprise-shipping-address`, params, config)
// /uec/delete/enterprise-shipping-address/{id}
const deleteAddress = (id) => mDelete(`/uec/delete/enterprise-shipping-address/${id}`, null, config)
const updateUserInfo = (params) => mPost('/uec/user/update/user-info', params, config)
const verifyCode = (code, params) => mGet(`/uec/verify/qrcode${code}`, params, config)
// ****************************************************************************************************************************************
// /authorize/by-wechat-applet小程序登录
@ -116,7 +81,6 @@ function unionWechat(form, resolve, reject) {
data: form,
method: 'POST',
success: function (result) {
wx.hideLoading()
if (result.data.code == 0) {
storage.remove('tempToken')
resolve(result.data)
@ -204,42 +168,23 @@ function phoneWechat(form) {
return promise
}
function finalizeToken() {
function finalizeToken(){
config.header = null
mconfig.header = null
pconfig.header = null
cconfig.header = null
sconfig.header = null
}
export {
config,
qrcodeEmploye,
verifyCode,
checkTestCode,
wechatApplet,
authCaptcha,
verifyCaptcha,
finalizeToken,
wechatApplet,
getUserInfo,
getAuthSession,
certificateImage,
certificateIdentity,
updateUserInfo,
postCaptcha,
loginPwd,
loginCaptcha,
phoneWechat,
loginWechat,
bindingAdmin,
bindingAccount,
getCheckList,
getEmployeList,
auditEmploye,
deleteEmploye,
adminEmploye,
getAddressList,
saveAddress,
getAddressInfo,
deleteAddress,
finalizeToken
}
// module.exports = {
// phoneWechat: phoneWechat,
// loginWechat: loginWechat
// }
setPassword,
modifyMobile,
verifyCode
}

1
pages/home/index/index.js

@ -1,7 +1,6 @@
// pages/stock/index.js
import Dialog from '../../../components/dialog/dialog'
import { finalizeToken } from "../../api/user"
import { getCreditInfo } from "../../api/payment"
const util = require('../../../utils/util')
const event = require('../../../utils/event.js')
const app = getApp()

18
pages/home/index/index.wxml

@ -47,23 +47,7 @@
<view class="text-gray text-sm">查看订单明细</view>
</view>
</view>
</view>
<!-- 订单信息 -->
<view wx:if="{{userInfo.position == 'PRIMARY' || userInfo.position == 'ADMINISTRATOR'}}" style="margin-top: 16rpx">
<van-cell-group>
<van-cell is-link value="查看全部订单" link-type="navigateTo" url="/pages/mall/order-list/index">
<view class="flex" slot="title" style="align-items: center">
<text class="text-sg" style="margin-left:12rpx">商城订单</text>
</view>
</van-cell>
</van-cell-group>
<van-grid square clickable column-num="4">
<van-grid-item icon="cash-back-record" url="/pages/mall/order-list/index?index=1" text="待付款" />
<van-grid-item icon="clock-o" url="/pages/mall/order-list/index?index=2" text="待发货" />
<van-grid-item icon="logistics" url="/pages/mall/order-list/index?index=3" text="待收货" />
<van-grid-item icon="notes-o" url="/pages/mall/order-list/index?index=4" text="已完成" />
</van-grid>
</view>
</view>
<!-- 企业信息 -->
<view style="height:16rpx"></view>
<van-cell-group>

171
pages/index/index.js

@ -1,12 +1,4 @@
// pages/administ/index.js
import Dialog from '../../components/dialog/dialog'
import { config, getUserInfo, verifyCode } from "../api/user"
// import { loginToken, cconfig } from "../api/cloud"
// import { mconfig } from "../api/mall"
import { pconfig } from "../api/payment"
const storage = require('../../utils/storage')
const event = require('../../utils/event')
const util = require('../../utils/util')
const app = getApp()
Page({
@ -21,11 +13,7 @@ Page({
{ index: 1, value: 'work', badge: 0, name: '工作台', blue: '/assets/image/tabbar/process-blue.png', gray: '/assets/image/tabbar/process-gray.png' },
{ index: 2, value: 'home', badge: 0, name: '我的', blue: '/assets/image/tabbar/home-blue.png', gray: '/assets/image/tabbar/home-gray.png' }
],
tabIndex: 0,
inited: false,
authorization: null,
code: null,
// code: '?mark=cloudprint&QrCodeRecordId=541755014083907584'
tabIndex: 0
},
/************************************** 初始化流程 ********************************************/
onLoad: function (options) {
@ -35,157 +23,11 @@ Page({
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
updateManager.applyUpdate()
})
if(options.q){
//扫二维码进入的,
let q = decodeURIComponent(options.q)
this.data.code = q.substring(q.indexOf('?'))
}
event.on('EventMessage', this, this.onEvent)
},
onReady: function () {
wx.showLoading({ title: '获取中', mask: true })
wx.getSystemInfo({
success: e => {
app.globalData.isIPhoneX = this.checkIPhoneX(e)
app.globalData.isIos = this.checkIos(e)
app.globalData.dev = e.platform == 'devtools'
let custom = wx.getMenuButtonBoundingClientRect()
app.globalData.Custom = custom
// 顶部操作栏高度
app.globalData.CustomBar = custom.bottom + custom.top - e.statusBarHeight + (app.globalData.isIos ? 4 : 0)
let windowHeight = e.windowHeight * (750 / e.windowWidth)
let safeBottom = e.windowHeight - e.safeArea.bottom
if(safeBottom > e.windowHeight){
safeBottom = 34
}
app.globalData.safeBottom = safeBottom * (750 / e.windowWidth)
// 状态栏高度
app.globalData.StatusBar = e.statusBarHeight * (750 / e.windowWidth)
let statusBarHeight = app.globalData.CustomBar * (750 / e.windowWidth)
app.globalData.statusBarHeight = statusBarHeight
// fragmentHeight:指的是整个页面statusBarHeight以下的高度
app.globalData.fragmentHeight = windowHeight - statusBarHeight
app.globalData.safeFragmentHeight = windowHeight - statusBarHeight - app.globalData.safeBottom
app.globalData.windowWidth = e.windowWidth
this.data.inited = true
const fheght = (app.globalData.safeFragmentHeight + app.globalData.statusBarHeight) - 100
event.emit('InitMessage', { what: 8, desc: 'Inited' })
this.setData({fragment: fheght, safeBottom: app.globalData.safeBottom, inited: true })
this.data.authorization = app.globalData.token || storage.get('Authorization')
if(this.data.code){
// 进入登录绑定页面
this.fetchCode(this.data.code)
} else if(this.data.authorization){
app.globalData.token = this.data.authorization
this.fetchUserInfo()
} else {
wx.hideLoading()
this.onResume()
}
}
})
},
checkIos: function (e) {
if ('ios' === e.platform) {
return true
}
if (e.system.startsWith('iOS')) {
return true
}
return false
},
checkIPhoneX: function (e) {
var t = e.model
return (/iPhone 11/.test(t) || /iPhone X/.test(t) || /iPhone 12/.test(t)) && this.checkIos(e)
},
/************************************** 登录流程 ********************************************/
onEvent: function (message) {
if (message.what == 888) {
if(!app.accountInfo){
this.setData({ tabIndex: 0 })
} else if(app.accountInfo && app.accountInfo.applicationStatus == 0){
this.setData({ tabIndex: 1 })
}
}
},
fetchUserInfo: function(){
if(!app.globalData.token){
wx.hideLoading()
this.onResume()
return
}
config.header = { 'Authorization': 'QNT ' + app.globalData.token }
getUserInfo().then(result => {
if (result.data.token) {
storage.put('Authorization', result.data.token)
app.globalData.token = result.data.token
}
app.accountInfo = result.data
loginToken({loginToken: app.globalData.token}).then(result => {
mconfig.header = { 'Authorization': 'QNT ' + result.data }
cconfig.header = { 'Authorization': 'QNT ' + result.data }
pconfig.header = { 'Authorization': 'QNT ' + result.data }
// 登录流程完成;
wx.hideLoading()
// 如果是员工,或者
if(app.accountInfo && app.accountInfo.applicationStatus == 0){
this.setData({ tabIndex: 1 })
}
this.onResume()
// event.emit('EventMessage', { what: 888, desc: 'Logined' })
}).catch(err => {
wx.hideLoading()
this.onResume()
})
}).catch(err => {
wx.hideLoading()
this.onResume()
})
},
// 根据二维码的code获取相关的内容;
fetchCode: function(code){
verifyCode(code).then(result => {
this.data.code = null
if(result.data.redirectUrl == '/login'){
// 根据userId来获取用户信息;并且直接登录
app.globalData.token = result.data.metaData.token
storage.put('Authorization', app.globalData.token)
this.fetchUserInfo()
} else if('/page/index/yaoqing' == result.data.redirectUrl || '/page/index/shenqing' == result.data.redirectUrl){
storage.put('metaData', JSON.stringify(result.data), 1)
wx.hideLoading()
// 进入login页面;
wx.navigateTo({ url: '/pages/index/index?code=11' })
} else {
wx.hideLoading()
if(!result.data.message){
result.data.message = '二维码解析失败,请重新扫码'
}
util.showToast(result.data.message)
}
}).catch(err => {
//异常回调
wx.hideLoading()
if(this.data.authorization){
Dialog.alert({ title: '温馨提示', message: '二维码解析失败,以当前账号进行登录!' }).then(() => {
wx.showLoading({ title: '登录中', mask: true })
app.globalData.token = this.data.authorization
this.fetchUserInfo()
})
} else {
util.showToast(err)
this.onResume()
}
})
this.setData({fragment: (app.globalData.safeFragmentHeight + app.globalData.statusBarHeight) - 100, safeBottom: app.globalData.safeBottom })
},
/************************************** 生命周期函数--监听页面初次渲染完成 ********************************************/
onShow: function () {
if(this.data.inited){
this.onResume()
}
this.onResume()
},
onResume: function(){
var pageView = this.selectComponent('#' + this.data.tabList[this.data.tabIndex].value)
@ -194,17 +36,10 @@ Page({
}
},
onChange: function ({detail}) {
if(detail == 2 && !app.accountInfo){
wx.navigateTo({ url: '/pages/login/index' })
return
}
this.setData({ tabIndex: detail })
this.onResume()
},
stopTouchMove: function(e){
return false
},
onUnload: function(){
event.remove('EventMessage', this)
}
})

3
pages/index/index.json

@ -5,7 +5,6 @@
"van-tabbar-item": "/components/tabbar-item/index",
"mall": "/pages/mall/index/index",
"workbench": "/pages/process/index/index",
"home": "/pages/home/index/index",
"van-dialog": "/components/dialog/index"
"home": "/pages/home/index/index"
}
}

4
pages/index/index.wxml

@ -1,11 +1,11 @@
<!--pages/administ/index.wxml-->
<swiper current="{{tabIndex}}" duration="0" style="height:{{fragment}}rpx" wx:if="{{inited}}">
<swiper current="{{tabIndex}}" duration="0" style="height:{{fragment}}rpx">
<swiper-item catchtouchmove="stopTouchMove"><mall id="{{tabList[0].value}}"/></swiper-item>
<swiper-item catchtouchmove="stopTouchMove"><workbench id="{{tabList[1].value}}"/></swiper-item>
<swiper-item catchtouchmove="stopTouchMove"><home id="{{tabList[2].value}}"/></swiper-item>
</swiper>
<view class="bg-white foot" style="height:{{100 + safeBottom}}rpx;padding-bottom:{{safeBottom}}rpx" wx:if="{{inited}}">
<view class="bg-white foot" style="height:{{100 + safeBottom}}rpx;padding-bottom:{{safeBottom}}rpx">
<van-tabbar active="{{ tabIndex }}" fixed="{{false}}" bind:change="onChange">
<van-tabbar-item wx:for="{{tabList}}" wx:key="index" >
<van-icon slot="icon" name="{{item.gray}}" size="25"/>

263
pages/login/index.js

@ -1,12 +1,9 @@
//获取应用实例
import Dialog from '../../components/dialog/dialog'
import { config, wechatApplet, getUserInfo, loginWechat, authCaptcha, verifyCaptcha, bindingAdmin, bindingAccount } from "../api/user"
// import { loginToken, cconfig } from "../api/cloud"
// import { mconfig } from "../api/mall"
import { pconfig } from "../api/payment"
import { config, postCaptcha, loginCaptcha, loginPwd, verifyCode } from "../api/user"
import { sconfig, loginToken, getBaseInfo } from "../api/saas"
const util = require('../../utils/util')
const storage = require('../../utils/storage')
const event = require('../../utils/event')
const app = getApp()
Page({
@ -23,145 +20,106 @@ Page({
captcha: null
},
loging: false,
regist: false,
qrPage: null,
metaData: null,
code: null,
checked: true,
height: app.globalData.fragmentHeight
code: null
},
/************************************** 初始化登录流程 ********************************************/
onLoad: function (options) {
var json = storage.get('metaData')
if(options.code && json){
//分享带code进入的,
this.setData({ code: options.code, height: app.globalData.fragmentHeight })
storage.remove('metaData')
var form = JSON.parse(json)
this.data.metaData = form.metaData
this.data.qrPage = form.redirectUrl
} else {
this.setData({ height: app.globalData.fragmentHeight })
}
this.wxLogin()
},
onEvent: function (message) {
if (message.what == 888) {
this.initAccountInfo()
const updateManager = wx.getUpdateManager()
updateManager.onCheckForUpdate()
updateManager.onUpdateReady(function () {
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
updateManager.applyUpdate()
})
if(options.q){
//扫二维码进入的,
let q = decodeURIComponent(options.q)
this.data.code = q.substring(q.indexOf('?'))
}
},
wxLogin: function(){
wx.login({
success: res => {
// 获取openId
wechatApplet({ authCode: res.code }).then(result => {
storage.put('tmpAuthToken', result.data.tmpAuthToken, 98)
})
onReady: function () {
wx.getSystemInfo({
success: e => {
app.globalData.isIos = this.checkIos(e)
app.globalData.dev = e.platform == 'devtools'
let custom = wx.getMenuButtonBoundingClientRect()
app.globalData.Custom = custom
// 顶部操作栏高度
app.globalData.CustomBar = custom.bottom + custom.top - e.statusBarHeight + (app.globalData.isIos ? 4 : 0)
let windowHeight = e.windowHeight * (750 / e.windowWidth)
let safeBottom = e.windowHeight - e.safeArea.bottom
if(safeBottom > e.windowHeight){
safeBottom = 34
}
app.globalData.safeBottom = safeBottom * (750 / e.windowWidth)
// 状态栏高度
app.globalData.StatusBar = e.statusBarHeight * (750 / e.windowWidth)
let statusBarHeight = app.globalData.CustomBar * (750 / e.windowWidth)
app.globalData.statusBarHeight = statusBarHeight
// fragmentHeight:指的是整个页面statusBarHeight以下的高度
app.globalData.fragmentHeight = windowHeight - statusBarHeight
app.globalData.safeFragmentHeight = windowHeight - statusBarHeight - app.globalData.safeBottom
app.globalData.windowWidth = e.windowWidth
if(this.data.code){
this.fetchQrCode(this.data.code)
} else {
this.fetchUserInfo()
}
}
})
},
// 获取用户信息,进行登录
checkIos: function (e) {
if ('ios' === e.platform) {
return true
}
if (e.system.startsWith('iOS')) {
return true
}
return false
},
/************************************** 获取用户信息,进行登录 ********************************************/
fetchUserInfo: function(){
config.header = { 'Authorization': 'QNT ' + app.globalData.token }
var authorization = app.globalData.token || storage.get('Authorization')
if (util.isEmpty(authorization)) {
return
}
app.globalData.token = authorization
config.header = { 'Authorization': 'QNT ' + authorization }
this.setData({ loging: true})
getUserInfo().then(result => {
this.setData({ loging: false})
if(!result.data.mobile){
wx.hideLoading()
//小白用户;注册流程;
this.setData({ regist: true })
return
}
if (result.data.token) {
storage.put('Authorization', result.data.token)
app.globalData.token = result.data.token
}
app.accountInfo = result.data
if(result.data.enterpriseId){
// 企业不一致
var invaild = false
if(this.data.metaData && this.data.metaData.enterpriseId){
invaild = result.data.enterpriseId != this.data.metaData.enterpriseId
} else if(this.data.metaData && this.data.metaData.joiningEnterprisePublicInvitationId){
invaild = result.data.enterpriseId != this.data.metaData.joiningEnterprisePublicInvitationId
}
if(invaild){
wx.hideLoading()
Dialog.alert({ title: '温馨提示', message: '您已经绑定过企业,现在就进入?' }).then(() => {
this.toIndex()
})
} else {
this.toIndex()
}
} else if(this.data.metaData){
// 如果有metaData
loginToken({loginToken: app.globalData.token}).then(result => {
sconfig.header = { 'Authorization': 'QNT ' + result.data.token }
getBaseInfo().then(result => {
this.setData({ loging: false})
app.userInfo = result.data
wx.hideLoading()
this.setData({ metaData: this.data.metaData, qrPage: this.data.qrPage, regist: false, loging: false })
} else {
//如果绑定过手机号码;
wx.redirectTo({ url: '/pages/index/index' })
}).catch(err => {
wx.hideLoading()
this.toIndex()
}
util.showToast(err)
app.globalData.token = null
storage.remove('Authorization')
config.header = null
this.setData({ loging: false})
})
}).catch(err => {
//异常回调
wx.hideLoading()
util.showToast(err)
app.globalData.token = null
storage.remove('Authorization')
config.header = null
this.setData({ loging: false})
})
},
toIndex: function(){
loginToken({loginToken: app.globalData.token}).then(result => {
mconfig.header = { 'Authorization': 'QNT ' + result.data }
cconfig.header = { 'Authorization': 'QNT ' + result.data }
pconfig.header = { 'Authorization': 'QNT ' + result.data }
// 登录完成...
wx.hideLoading()
event.emit('EventMessage', { what: 888, desc: 'Logined' })
wx.navigateBack()
}).catch(err => {
wx.hideLoading()
})
},
onBoxChange: function({detail}){
this.setData({ checked: detail })
},
/************************************** 注册流程 ********************************************/
readAgreement: function () {
wx.navigateTo({ url: '/pages/htmls/agreement/index' })
},
onGotUserInfo: function (e) {
if(!this.data.checked){
util.showToast('请阅读并同意《服务与隐私协议》')
return
}
if(this.data.loging){
return
}
this.setData({ loging: true })
if(this.data.form.tmpAuthToken){
this.registAccount()
return
}
loginWechat({ encryptedData: e.detail.encryptedData, iv: e.detail.iv }).then(result => {
storage.put('Authorization', result.data.token)
app.globalData.token = result.data.token
this.data.form.tmpAuthToken = result.data.tmpAuthToken
if(e.currentTarget.id == 'btn-login'){
this.registAccount()
} else {
this.fetchUserInfo()
}
}).catch(error => {
if(error.data && error.data.tmpAuthToken){
this.data.form.tmpAuthToken = error.data.tmpAuthToken
this.setData({ regist: true, loging: false })
} else {
this.setData({ loging: false })
}
util.showToast(error.message)
})
},
inputFocus: function(e) {
storage.put('keyboardHeight', e.detail.height)
app.globalData.keyboardHeight = e.detail.height
},
bindInput: function (e) {
this.data.form[e.target.id] = e.detail.value
@ -191,16 +149,13 @@ Page({
onFinished: function(){
this.setData({ second: '重新获取验证码', codeEnable: true })
},
loginFrom: function(){
this.setData({ regist: true })
},
fetchCaptcha: function(){
if (!(/^1\d{10}$/.test(this.data.form.account)) || this.data.form.account.length < 11) {
util.showToast('请输入11位手机号码')
return
}
wx.showLoading({ title: '正在获取', mask: true })
authCaptcha({ verifiableAccount: this.data.form.account, verifiableAccountType: 1, purpose: 1 }).then(result => {
postCaptcha({ verifiableAccount: this.data.form.account, verifiableAccountType: 1, purpose: 1 }).then(result => {
wx.hideLoading()
this.setData({ codeEnable: false })
util.showToast('验证码已经发送')
@ -227,45 +182,53 @@ Page({
}
wx.showLoading({ title: '登录中', mask: true })
this.setData({ loging: true })
// this.data.form.password = md5.hexMD5(this.data.form.password).toUpperCase()
if (this.data.type == 1) {
verifyCaptcha(this.data.form).then(result => {
wx.setStorageSync('Authorization', result.data.token)
loginCaptcha(this.data.form).then(result => {
storage.put('Authorization', result.data.token)
app.globalData.token = result.data.token
this.fetchUserInfo()
}).catch(error => {
wx.hideLoading()
this.setData({ loging: false })
console.log(error)
util.showToast(error)
})
} else {
// authorize/by-password 密码登录
}
},
/************************************** 二维码流程 ********************************************/
bindAccount: function(){
if (util.isEmpty(this.data.form.userName)) {
util.showToast('请输入您的姓名,以便于识别')
return
}
this.setData({ loging: true })
this.data.metaData.userName = this.data.form.userName
if(this.data.qrPage == '/page/index/yaoqing'){
bindingAdmin(this.data.metaData).then(result => {
this.data.metaData = null
loginPwd(this.data.form).then(result => {
storage.put('Authorization', result.data.token)
app.globalData.token = result.data.token
this.fetchUserInfo()
}).catch(error => {
this.setData({loging: false})
wx.hideLoading()
util.showToast(error)
})
}
},
changeType: function () {
if (this.data.type == 1) {
this.setData({ type: 0, ['form.captcha']: null, loginEnable: true })
} else {
bindingAccount(this.data.metaData).then(result => {
this.data.metaData = null
this.fetchUserInfo()
}).catch(error => {
this.setData({loging: false})
util.showToast(error)
})
this.setData({ type: 1, ['form.password']: null, loginEnable: true })
}
},
/************************************** 二维码流程 ********************************************/
fetchQrCode: function(code){
verifyCode(code).then(result => {
this.data.code = null
if(result.data.redirectUrl == '/login'){
// 根据userId来获取用户信息;并且直接登录
app.globalData.token = result.data.metaData.token
storage.put('Authorization', app.globalData.token)
this.fetchUserInfo()
} else {
wx.hideLoading()
if(!result.data.message){
result.data.message = '二维码解析失败,请重新扫码'
}
util.showToast(result.data.message)
}
}).catch(err => {
//异常回调
wx.hideLoading()
})
}
})

3
pages/login/index.json

@ -2,7 +2,6 @@
"usingComponents": {
"van-button": "/components/button/index",
"van-dialog": "/components/dialog/index",
"van-count-down": "/components/count-down/index",
"van-checkbox": "/components/checkbox/index"
"van-count-down": "/components/count-down/index"
}
}

121
pages/login/index.wxml

@ -1,94 +1,49 @@
<!--pages/login/index.wxml-->
<cu-custom bgColor="bg-white" isBack="{{!code}}" shadow="{{code}}">
<view slot="content" style="color:black;font-size:36rpx">登录</view>
</cu-custom>
<view class="flex flex-center" style="width:100%;height:320rpx;margin-top:120rpx">
<image style="width:192rpx;height:192rpx" src="/assets/image/icon_logo.png"></image>
</view>
<view wx:if="{{metaData || regist}}">
<view class="flex flex-center" style="width:100%;height:320rpx">
<image style="width:182rpx;height:203rpx" src="/assets/image/icon_logo.png"></image>
<view style="padding: 30rpx 80rpx">
<view class="flex">
<image style="width:40rpx;height:40rpx" src="/assets/image/icon_phone.png"></image>
<text class="label" style="margin-left:24rpx">手机号码</text>
</view>
<view wx:if="{{metaData}}" style="padding:30rpx 60rpx;height:400rpx">
<view class="text-xl">欢迎您使用千鸟跟单王!</view>
<view class="text-df" style="padding:20rpx 0rpx" wx:if="{{qrPage == '/page/index/yaoqing'}}">
<text class="text-df">现邀请您成为<text class="text-bold text-blue">{{metaData.name}}</text>的管理员</text>
</view>
<view class="text-df" style="padding:20rpx 0rpx" wx:elif="{{qrPage == '/page/index/shenqing'}}">
<text class="text-df">现邀请您成为<text class="text-bold text-blue">{{metaData.name}}</text>的员工</text>
</view>
<view class="cu-form-group" style="min-height:120rpx;padding:48rpx 0rpx;">
<input id="userName" style="padding:0rpx 30rpx;border:1rpx solid #eee;height:80rpx" placeholder-style="color:#aaa"
maxlength="11" placeholder="请输入您的姓名,以便于识别" bindinput="bindInput" disabled="{{loging}}" bindfocus="inputFocus" />
</view>
<view class="flex flex-center" style="margin-top:30rpx;padding:30rpx 60rpx;">
<van-button custom-style="width:630rpx" type="info" loading="{{loging}}" loading-text="登录中..." bind:click="bindAccount">提交</van-button>
</view>
<view class="cu-form-group" style="min-height:120rpx;border-bottom:1rpx solid #eee;padding:0rpx">
<input id="account" type="number" placeholder-style="color:#aaa" maxlength="11" placeholder="请输入手机号" value="{{form.account}}" bindinput="bindInput" />
</view>
<view style="padding: 0rpx 80rpx" wx:elif="{{regist}}">
<view class="flex">
<image style="width:40rpx;height:40rpx" src="/assets/image/icon_phone.png"></image>
<text class="label" style="margin-left:24rpx">手机号码</text>
</view>
<view class="cu-form-group" style="min-height:120rpx;border-bottom:1rpx solid #eee;padding:0rpx">
<input id="account" type="number" placeholder-style="color:#aaa" maxlength="11" placeholder="请输入手机号"
value="{{form.account}}" bindinput="bindInput" />
</view>
<view class="flex" style="margin-top: 40rpx">
<image style="width:40rpx;height:40rpx"
src="{{type == 1 ? '/assets/image/icon_code.png' : '/assets/image/icon_pwd.png'}}"></image>
<text class="label" style="margin-left:12rpx">{{type == 1 ? '验证码' : '密码'}}</text>
</view>
<view wx:if="{{type == 1}}" class="cu-form-group" style="margin-top: 40rpx;min-height:120rpx;border-bottom:1rpx solid #eee;padding:0rpx;border-top:0rpx solid #eee;">
<!-- <text class="label" style="margin-left:12rpx;margin-right:24rpx">{{type == 1 ? '验证码' : '密码'}}</text> -->
<input id="captcha" type="number" placeholder-style="color:#aaa" maxlength="6" placeholder="请输入{{type == 1 ? '验证码' : '密码'}}"
bindinput="bindInput" />
<van-button size="small" plain type="info" custom-style="width:220rpx" disabled="{{!mobileEnable || !codeEnable}}"
bind:click="fetchCaptcha">
<van-count-down class="count-down" time="{{ 60000 }}" use-slot auto-start="{{false}}" bind:change="onChange"
bind:finish="onFinished">
<text class="text-sm">{{second}}</text>
</van-count-down>
</van-button>
</view>
<view wx:else class="cu-form-group" style="min-height:120rpx;border-bottom:1rpx solid #eee;padding:0rpx">
<input id="password" placeholder-style="color:#aaa" type="{{pwdType}}" maxlength="20" placeholder="请输入验密码"
bindinput="bindInput" bindfocus="inputFocus" />
</view>
<view class="flex flex-center" style="margin-top:30rpx;padding:30rpx 60rpx;">
<van-button id="btn-login" custom-style="width:630rpx" type="info" loading="{{loging}}" loading-text="登录中..."
disabled="{{loginEnable}}" open-type="getUserInfo" bind:getuserinfo="onGotUserInfo">登录
</van-button>
</view>
<view class="flex" style="margin-top: 40rpx">
<image style="width:40rpx;height:40rpx" src="{{type == 1 ? '/assets/image/icon_code.png' : '/assets/image/icon_pwd.png'}}"></image>
<text class="label" style="margin-left:12rpx">{{type == 1 ? '验证码' : '密码'}}</text>
</view>
<view wx:if="{{type == 1}}" class="cu-form-group" style="min-height:120rpx;border-bottom:1rpx solid #eee;padding:0rpx;border-top:0rpx solid #eee;">
<input id="captcha" type="number" placeholder-style="color:#aaa" maxlength="6" placeholder="请输入{{type == 1 ? '验证码' : '密码'}}" bindinput="bindInput" />
<van-button size="small" plain type="info" custom-style="width:220rpx" disabled="{{!mobileEnable || !codeEnable}}" bind:click="fetchCaptcha">
<van-count-down class="count-down" time="{{ 60000 }}" use-slot auto-start="{{false}}" bind:change="onChange" bind:finish="onFinished">
<text class="text-sm">{{second}}</text>
</van-count-down>
</van-button>
</view>
<view wx:else class="cu-form-group" style="min-height:120rpx;border-bottom:1rpx solid #eee;padding:0rpx">
<input id="password" placeholder-style="color:#aaa" type="{{pwdType}}" maxlength="20" placeholder="请输入验密码" bindinput="bindInput" bindfocus="inputFocus" />
</view>
<view style="margin-top:24rpx;text-align:end;">
<text class="label" style="font-size:30rpx;padding: 12rpx 0rpx 12rpx 24rpx" bindtap="changeType">{{type == 1 ? '密码登录' : '验证码登录'}}</text>
</view>
</view>
<view style="margin-top:80rpx;padding:40rpx 80rpx">
<van-button block type="info" loading="{{loging}}" loading-text="登录中..." disabled="{{loginEnable}}" bind:click="registAccount">登录</van-button>
</view>
<view class="relative" wx:else>
<image style="width:750rpx;height:{{height}}rpx;position:absolute" src="/assets/image/bg-logo.png"></image>
<view class="container" style="padding: 0rpx 32rpx">
<view style="text-align: center;color:white" class="text-xxl text-bold">千鸟互联云印通</view>
<view style="text-align: center;color:white;margin-top:12rpx" class="text-xxl text-bold">专注服务于印刷包装企业</view>
<view class="bg-white flex flex-center flex-column"
style="margin-top:30rpx;padding:48rpx 32rpx;border-radius: 30rpx">
<van-button round custom-style="width:620rpx" type="primary" loading="{{loging}}" loading-text="登录中..."
open-type="getUserInfo" bind:getuserinfo="onGotUserInfo">
<text class="cuIcon-weixin text-white" style="font-size:44rpx"></text>
<text class="text-xl">微信用户一键登录</text>
</van-button>
<van-button round plain custom-style="width:620rpx;margin-top:32rpx" type="default" bind:click="loginFrom">
<text class="text-xl">手机验证码登录</text>
</van-button>
<view class="flex flex-center text-sm" style="margin-top:32rpx">
<van-checkbox value="{{ checked }}" shape="square" bind:change="onBoxChange" icon-size="12px">
<text class="text-gray text-sm">登录即同意</text>
</van-checkbox>
<text class="text-blue" bindtap="readAgreement" style="padding-bottom:5rpx">《服务与隐私协议》</text>
</view>
<!-- <text class="cuIcon-infofill md-icon" style="margin-top:30rpx">仅限千鸟跟单王用户使用</text> -->
</view>
</view>
<!-- <view style="margin-top:30rpx;padding:30rpx 60rpx;">
<van-button block type="info" loading="{{loging}}" loading-text="登录中..." disabled="{{loginEnable}}"
wx:if="{{metaData && token}}" bind:click="bindAccount">提交</van-button>
<van-button block type="info" loading="{{loging}}" loading-text="登录中..." open-type="getUserInfo"
bind:getuserinfo="onGotUserInfo" wx:else>同意</van-button>
</view> -->
<view class="flex flex-center" style="margin-top:10rpx;font-size:24rpx;color:#008AFF;text-align: center">
<text class="cuIcon-infofill md-icon">仅限纸通宝工厂用户使用</text>
</view>
<van-dialog id="van-dialog" />

13
pages/login/index.wxss

@ -3,19 +3,6 @@ page {
background-color: #fff;
}
.relative{
height: 100%;
width: 100%;
position:relative;
}
.container {
width: 100%;
flex-direction: column;
position: fixed;
bottom: 64rpx;
}
.label {
font-size: 30rpx;
font-family: PingFang-SC-Regular, PingFang-SC;

23
pages/mall/components/cell/index.js

@ -1,23 +0,0 @@
// pages/mall/components/sku.js
Component({
/**
* 组件的属性列表
*/
properties: {
},
/**
* 组件的初始数据
*/
data: {
},
/**
* 组件的方法列表
*/
methods: {
}
})

4
pages/mall/components/cell/index.json

@ -1,4 +0,0 @@
{
"component": true,
"usingComponents": {}
}

2
pages/mall/components/cell/index.wxml

@ -1,2 +0,0 @@
<!--pages/mall/components/sku.wxml-->
<text>pages/mall/components/sku.wxml</text>

1
pages/mall/components/cell/index.wxss

@ -1 +0,0 @@
/* pages/mall/components/sku.wxss */

23
pages/mall/components/fence/index.js

@ -1,23 +0,0 @@
// pages/mall/components/sku.js
Component({
/**
* 组件的属性列表
*/
properties: {
},
/**
* 组件的初始数据
*/
data: {
},
/**
* 组件的方法列表
*/
methods: {
}
})

4
pages/mall/components/fence/index.json

@ -1,4 +0,0 @@
{
"component": true,
"usingComponents": {}
}

2
pages/mall/components/fence/index.wxml

@ -1,2 +0,0 @@
<!--pages/mall/components/sku.wxml-->
<text>pages/mall/components/sku.wxml</text>

1
pages/mall/components/fence/index.wxss

@ -1 +0,0 @@
/* pages/mall/components/sku.wxss */

23
pages/mall/components/sku/index.js

@ -1,23 +0,0 @@
// pages/mall/components/sku.js
Component({
/**
* 组件的属性列表
*/
properties: {
},
/**
* 组件的初始数据
*/
data: {
},
/**
* 组件的方法列表
*/
methods: {
}
})

4
pages/mall/components/sku/index.json

@ -1,4 +0,0 @@
{
"component": true,
"usingComponents": {}
}

2
pages/mall/components/sku/index.wxml

@ -1,2 +0,0 @@
<!--pages/mall/components/sku.wxml-->
<text>pages/mall/components/sku.wxml</text>

1
pages/mall/components/sku/index.wxss

@ -1 +0,0 @@
/* pages/mall/components/sku.wxss */

10
pages/process/index/index.json

@ -1,9 +1,11 @@
{
"component": true,
"usingComponents": {
"van-tabs": "/components/tabs/index",
"van-tab": "/components/tab/index",
"van-loading": "/components/loading/index",
"van-button": "/components/button/index"
"van-grid": "/components/grid/index",
"van-grid-item": "/components/grid-item/index",
"van-cell": "/components/cell/index",
"van-cell-group": "/components/cell-group/index",
"van-info": "/components/info/index",
"van-icon": "/components/icon/index"
}
}

58
pages/process/index/index.wxml

@ -2,47 +2,17 @@
<cu-custom bgColor="bg-white">
<view slot="content" style="color:black;font-size:36rpx">工作台</view>
</cu-custom>
<!-- loading-->
<view class="list-empty" style="height:1200rpx" wx:if="{{loading}}">
<van-loading type="spinner" size="32" />
<view class="text-empty">正在加载</view>
</view>
<!-- 普通员工-->
<van-tabs sticky active="{{tabIndex}}" color="#008AFF" bind:change="onTabChange" line-height="2px" wx:elif="{{userInfo && userInfo.position == 'ORDINARY'}}">
<van-tab wx:for="{{tabList}}" wx:key="index" title="{{item.name}}" title-style="color:{{tabIndex==index?'#008AFF':'#333333'}}">
<production id="{{item.value}}" status="{{item.status}}"></production>
</van-tab>
</van-tabs>
<!-- 管理员 -->
<van-tabs sticky active="{{tabIndex}}" color="#008AFF" bind:change="onTabChange" line-height="2px" wx:elif="{{userInfo && userInfo.position}}">
<van-tab title="{{tabList[0].name}}" title-style="color:{{tabIndex==0?'#008AFF':'#333333'}}">
<supply id="{{tabList[0].value}}"></supply>
</van-tab>
<van-tab title="{{tabList[1].name}}" title-style="color:{{tabIndex==1?'#008AFF':'#333333'}}">
<purchase id="{{tabList[1].value}}"></purchase>
</van-tab>
<van-tab title="{{tabList[2].name}}" title-style="color:{{tabIndex==2?'#008AFF':'#333333'}}">
<production id="{{tabList[2].value}}"></production>
</van-tab>
</van-tabs>
<!-- 待审核的员工 -->
<view class="list-empty bg-white" style="height:{{height}}rpx" wx:elif="{{userInfo && userInfo.applicationStatus == 0}}">
<image style="width:182rpx;height:203rpx" src="/assets/image/icon_logo.png"></image>
<view class="text-empty">您的申请还在审核中,如有疑问请联系管理员。</view>
</view>
<!-- 小白用户 -->
<view class="list-empty" style="height:{{height}}rpx" wx:elif="{{userInfo && !userInfo.enterpriseId}}">
<image style="width:182rpx;height:203rpx" src="/assets/image/icon_logo.png"></image>
<view class="text-empty">您还没有入驻云印通</view>
<van-button round plain custom-style="width:320rpx;margin-top:56rpx" type="default" bind:click="applyFrom">
<text class="text-df">现在去申请</text>
</van-button>
</view>
<!-- 没有登录 -->
<view class="list-empty" style="height:{{height}}rpx" wx:else>
<image style="width:182rpx;height:203rpx" src="/assets/image/icon_logo.png"></image>
<view class="text-empty">您还没有云印通账号</view>
<van-button round plain custom-style="width:320rpx;margin-top:56rpx" type="default" bind:click="loginFrom">
<text class="text-df">现在去登录</text>
</van-button>
</view>
<van-cell-group>
<van-cell is-link value="查看全部订单" link-type="navigateTo" url="/pages/mall/order-list/index">
<view class="flex" slot="title" style="align-items: center">
<text class="text-sg" style="margin-left:12rpx">收货管理</text>
</view>
</van-cell>
</van-cell-group>
<van-grid square clickable column-num="4">
<van-grid-item icon="cash-back-record" url="/pages/mall/order-list/index?index=1" text="待付款" />
<van-grid-item icon="clock-o" url="/pages/mall/order-list/index?index=2" text="待发货" />
<van-grid-item icon="logistics" url="/pages/mall/order-list/index?index=3" text="待收货" />
<van-grid-item icon="notes-o" url="/pages/mall/order-list/index?index=4" text="已完成" />
</van-grid>

2
project.config.json

@ -41,7 +41,7 @@
},
"compileType": "miniprogram",
"libVersion": "2.14.0",
"appid": "wx0e4e0fc5432db6d8",
"appid": "wx8214a7f3614a3340",
"projectname": "ztb-saas-mini",
"debugOptions": {
"hidedInDevtools": []

Loading…
Cancel
Save