Browse Source

production 1.0.0

devlop
邓雄飞 4 years ago
parent
commit
da5fc58b9d
9 changed files with 281 additions and 264 deletions
  1. 11
      components/bussiness-components/packingStationItem.vue
  2. 14
      pages.json
  3. 118
      pages/about/index.vue
  4. 2
      pages/add-account/index.vue
  5. 5
      pages/mine/index.vue
  6. 2
      pages/page-view/index.vue
  7. 1
      pages/switching-mall/index.vue
  8. 391
      store/index.js
  9. 1
      utils/hook.js

11
components/bussiness-components/packingStationItem.vue

@ -70,7 +70,7 @@
</template>
<script>
import { go2, loginGo2 } from '@/utils/hook.js'
import { go2 } from '@/utils/hook.js'
export default {
props: {
info: {
@ -93,7 +93,14 @@ export default {
},
methods: {
goDetail() {
loginGo2('client-detail', { id: this.info.enterpriseId })
// 使hook.jsloginGo2nvuestore == this.$store
const token = this.$store.state.qnToken
if (token) {
go2('client-detail', { id: this.info.enterpriseId }, false)
} else {
this.$store.commit('setNextPage', { name: 'client-detail', data:{ id: this.info.enterpriseId }})
go2('login')
}
},
transformBusiness(business) {
let text = business?.trim() || '未知'

14
pages.json

@ -1,5 +1,12 @@
{
"pages": [
{
"path": "pages/client/index",
"style": {
"navigationBarTitleText": "客户",
"navigationStyle": "custom"
}
},
{
"path": "pages/start-page/index",
"style": {
@ -8,13 +15,6 @@
"enablePullDownRefresh": false
}
},
{
"path": "pages/client/index",
"style": {
"navigationBarTitleText": "客户",
"navigationStyle": "custom"
}
},
{
"path": "pages/client-list/index",
"style": {

118
pages/about/index.vue

@ -1,71 +1,71 @@
<template>
<view class="about">
<view>
<uni-nav-bar left-icon="back" @clickLeft="back" statusBar fixed title="">
<view class="about-title">关于纸掌柜</view>
<view slot="left"></view>
<view slot="right"></view>
</uni-nav-bar>
</view>
<view class="about-main">
<view class=""><image class="about-image" src="../../static/logo.png" mode=""></image></view>
<view class="about-text"><text>纸掌柜</text></view>
<view class="about-subtext"><text>帮你卖好每一吨纸</text></view>
<view class="about-vs"><text>版本号 纸掌柜 V1.0.0</text></view>
</view>
</view>
<view class="about">
<view>
<uni-nav-bar left-icon="back" @clickLeft="back" statusBar fixed title="">
<view class="about-title">关于纸掌柜</view>
<view slot="left"></view>
<view slot="right"></view>
</uni-nav-bar>
</view>
<view class="about-main">
<view class=""><image class="about-image" src="../../static/logo.png" mode=""></image></view>
<view class="about-text"><text>纸掌柜</text></view>
<view class="about-subtext"><text>帮你卖好每一吨纸</text></view>
<view class="about-vs"><text>版本号 纸掌柜 V1.0.0</text></view>
</view>
</view>
</template>
<script>
import { back, go2, uploadFile } from '@/utils/hook.js'
import { back } from '@/utils/hook.js'
export default {
data() {
return {}
},
methods: {
back
}
data() {
return {}
},
methods: {
back
}
}
</script>
<style lang="scss">
.about {
.about-main {
text-align: center;
}
.about-title {
width: 100%;
font-size: 36rpx;
color: #000000;
letter-spacing: 0;
text-align: center;
font-weight: 500;
}
.about-image {
width: 160rpx;
height: 160rpx;
margin-top: 180rpx;
}
.about-text {
opacity: 0.8;
font-size: 64rpx;
color: #000000;
font-weight: 400;
margin-top: 40rpx;
}
.about-subtext {
font-size: 28rpx;
color: #555555;
letter-spacing: 0;
font-weight: 400;
margin-top: 18rpx;
}
.about-vs {
font-size: 28rpx;
color: #888888;
letter-spacing: 0;
font-weight: 400;
margin-top: 100rpx;
}
.about-main {
text-align: center;
}
.about-title {
width: 100%;
font-size: 36rpx;
color: #000000;
letter-spacing: 0;
text-align: center;
font-weight: 500;
}
.about-image {
width: 160rpx;
height: 160rpx;
margin-top: 180rpx;
}
.about-text {
opacity: 0.8;
font-size: 64rpx;
color: #000000;
font-weight: 400;
margin-top: 40rpx;
}
.about-subtext {
font-size: 28rpx;
color: #555555;
letter-spacing: 0;
font-weight: 400;
margin-top: 18rpx;
}
.about-vs {
font-size: 28rpx;
color: #888888;
letter-spacing: 0;
font-weight: 400;
margin-top: 100rpx;
}
}
</style>

2
pages/add-account/index.vue

@ -74,7 +74,7 @@
</template>
<script>
import { back, go2, uploadFile } from '@/utils/hook.js'
import { back } from '@/utils/hook.js'
import uGap from '@/components/u-gap/u-gap.vue'
import { addEmployee } from '@/apis/setting.js'
const validateFields = ['mobile', 'name', 'title']

5
pages/mine/index.vue

@ -5,7 +5,7 @@
<image class="bg" src="/static/imgs/mine/mine-top-bg.png"></image>
<view class="operation-area">
<view class="user">
<image class="avatar" :src="curAvatar"></image>
<image class="avatar" @click="test" :src="curAvatar"></image>
<view v-if="!hasLogin" @click="go2('login')">
<view>
<text style="font-size: 40rpx; color: #fff; font-weight: 600">点击登录</text>
@ -212,6 +212,9 @@ export default {
},
methods: {
test() {
loginGo2('client')
},
//
certifyCompany() {
if (!this.hasCompany) {

2
pages/page-view/index.vue

@ -5,7 +5,7 @@
</template>
<script>
import { go2, back, exit } from '@/utils/hook.js'
import { go2, back } from '@/utils/hook.js'
import { makeSocket } from '@/utils/index.js'
export default {
data() {

1
pages/switching-mall/index.vue

@ -33,7 +33,6 @@
<script>
import { back, go2 } from '@/utils/hook.js'
import { getStoreList } from '@/apis/add-paper.js'
import store from '@/store/index'
export default {
data() {
return {

391
store/index.js

@ -42,205 +42,212 @@ try {
}
Vue.use(Vuex)
const store = new Vuex.Store({
state: {
uecToken: uecToken || '',
qnToken: qnToken || '', // token
userInfo: userInfo || {}, // 用户信息
supplierInfo: supplierInfo || {}, // 纸盘商信息
nextPage: {
name: '',
data: {}
let store = null
if (!store) {
store = new Vuex.Store({
state: {
uecToken: uecToken || '',
qnToken: qnToken || '', // token
userInfo: userInfo || {}, // 用户信息
supplierInfo: supplierInfo || {}, // 纸盘商信息
nextPage: {
name: '',
data: {}
},
searchHistory: searchHistory || []
},
searchHistory: searchHistory || []
},
mutations: {
setUecToken(state, token) {
try {
uni.setStorageSync('uecToken', token)
state.uecToken = token
} catch (e) {
console.warn('更改uecToken失败:', e)
}
},
removeUecToken(state) {
try {
uni.removeStorageSync('uecToken')
state.uecToken = ''
} catch (e) {
console.warn('删除uecToken失败:', e)
}
},
setToken(state, token) {
try {
uni.setStorageSync('qnToken', token)
state.qnToken = token
} catch (e) {
console.warn('更改token失败:', e)
}
},
removeToken(state) {
try {
uni.removeStorageSync('qnToken')
state.qnToken = ''
} catch (e) {
console.warn('删除token失败:', e)
}
},
setUserInfo(state, userInfo) {
if (!isObject(userInfo)) {
console.warn('userInfo必须是对象')
return
}
for (let i = 0; i < userInfoParams.length; i++) {
if (userInfo[userInfoParams[i]] === undefined) {
console.warn('userInfo必须包含' + userInfoParams[i] + '属性')
mutations: {
setUecToken(state, token) {
try {
uni.setStorageSync('uecToken', token)
state.uecToken = token
} catch (e) {
console.warn('更改uecToken失败:', e)
}
},
removeUecToken(state) {
try {
uni.removeStorageSync('uecToken')
state.uecToken = ''
} catch (e) {
console.warn('删除uecToken失败:', e)
}
},
setToken(state, token) {
try {
uni.setStorageSync('qnToken', token)
console.log('设置token成功')
state.qnToken = token
} catch (e) {
console.warn('更改token失败:', e)
}
},
removeToken(state) {
try {
uni.removeStorageSync('qnToken')
console.log('删除token')
state.qnToken = ''
} catch (e) {
console.warn('删除token失败:', e)
}
},
setUserInfo(state, userInfo) {
if (!isObject(userInfo)) {
console.warn('userInfo必须是对象')
return
}
}
try {
uni.setStorageSync('userInfo', JSON.stringify(userInfo))
state.userInfo = userInfo
} catch (e) {
console.warn('设置userInfo失败:', e)
}
},
/**
* 更改当前用户信息
* @param {*} state 状态
* @param {arr} map 以key-value形式存储的数组
* @value key 需要更改的key
* @value value 更改后的值
*/
changeUserInfo(state, map) {
if (!isArray(map)) {
console.warn('map必须是数组')
return
}
let userInfo = state.userInfo
map.forEach((item) => {
if (userInfoParams.includes(item.key)) {
userInfo[item.key] = item.value
}
})
try {
uni.setStorageSync('userInfo', JSON.stringify(userInfo))
state.userInfo = userInfo
} catch (e) {
console.warn('更改userInfo失败:', e)
}
},
removeUserInfo(state) {
try {
uni.removeStorageSync('userInfo')
state.userInfo = {}
} catch (e) {
console.warn('删除userInfo失败:', e)
}
},
setSupplierInfo(state, supplierInfo) {
if (!isObject(supplierInfo)) {
console.warn('supplierInfo必须是对象')
return
}
for (let i = 0; i < supplierInfoParams.length; i++) {
if (supplierInfo[supplierInfoParams[i]] === undefined) {
console.warn(`supplierInfo必须包含${supplierInfoParams[i]}`)
for (let i = 0; i < userInfoParams.length; i++) {
if (userInfo[userInfoParams[i]] === undefined) {
console.warn('userInfo必须包含' + userInfoParams[i] + '属性')
return
}
}
try {
uni.setStorageSync('userInfo', JSON.stringify(userInfo))
state.userInfo = userInfo
} catch (e) {
console.warn('设置userInfo失败:', e)
}
},
/**
* 更改当前用户信息
* @param {*} state 状态
* @param {arr} map 以key-value形式存储的数组
* @value key 需要更改的key
* @value value 更改后的值
*/
changeUserInfo(state, map) {
if (!isArray(map)) {
console.warn('map必须是数组')
return
}
let userInfo = state.userInfo
map.forEach((item) => {
if (userInfoParams.includes(item.key)) {
userInfo[item.key] = item.value
}
})
try {
uni.setStorageSync('userInfo', JSON.stringify(userInfo))
state.userInfo = userInfo
} catch (e) {
console.warn('更改userInfo失败:', e)
}
},
removeUserInfo(state) {
try {
uni.removeStorageSync('userInfo')
state.userInfo = {}
} catch (e) {
console.warn('删除userInfo失败:', e)
}
},
setSupplierInfo(state, supplierInfo) {
if (!isObject(supplierInfo)) {
console.warn('supplierInfo必须是对象')
return
}
for (let i = 0; i < supplierInfoParams.length; i++) {
if (supplierInfo[supplierInfoParams[i]] === undefined) {
console.warn(`supplierInfo必须包含${supplierInfoParams[i]}`)
return
}
}
try {
uni.setStorageSync('supplierInfo', JSON.stringify(supplierInfo))
state.supplierInfo = supplierInfo
} catch (e) {
console.warn('设置supplierInfo失败:', e)
}
},
/**
* 更改当前供应商信息
* @param {*} state 状态
* @param {arr} map 以key-value形式存储的数组
* @value key 需要更改的key
* @value value 更改后的值
*/
changeSupplierInfo(state, map) {
if (!isArray(map)) {
console.warn('map必须是数组')
return
}
let supplierInfo = state.supplierInfo
map.forEach((item) => {
if (supplierInfoParams.includes(item.key)) {
supplierInfo[item.key] = item.value
}
})
try {
uni.setStorageSync('supplierInfo', JSON.stringify(supplierInfo))
state.supplierInfo = supplierInfo
} catch (e) {
console.warn('更改supplierInfo失败:', e)
}
},
removeSupplierInfo(state) {
try {
uni.removeStorageSync('supplierInfo')
state.supplierInfo = {}
} catch (e) {
console.warn('删除supplierInfo失败:', e)
}
},
setNextPage(state, nextPage) {
if (!isObject(nextPage)) {
console.warn('nextPage必须是对象')
return
}
state.nextPage.name = nextPage.name || ''
state.nextPage.data = nextPage.data || {}
},
removeNextPage(state) {
state.nextPage.name = ''
state.nextPage.data = {}
},
setSearchHistory(state, searchHistory) {
if (!isArray(searchHistory)) {
console.warn('searchHistory必须是数组')
return
}
try {
uni.setStorageSync('searchHistory', JSON.stringify(searchHistory))
state.searchHistory = searchHistory
} catch (e) {
console.warn('更改searchHistory失败:', e)
}
},
clearSearchHistory(state) {
try {
uni.removeStorageSync('searchHistory')
state.searchHistory = []
} catch (e) {
console.warn('删除searchHistory失败:', e)
}
}
try {
uni.setStorageSync('supplierInfo', JSON.stringify(supplierInfo))
state.supplierInfo = supplierInfo
} catch (e) {
console.warn('设置supplierInfo失败:', e)
}
},
/**
* 更改当前供应商信息
* @param {*} state 状态
* @param {arr} map 以key-value形式存储的数组
* @value key 需要更改的key
* @value value 更改后的值
*/
changeSupplierInfo(state, map) {
if (!isArray(map)) {
console.warn('map必须是数组')
return
}
let supplierInfo = state.supplierInfo
map.forEach((item) => {
if (supplierInfoParams.includes(item.key)) {
supplierInfo[item.key] = item.value
}
})
try {
uni.setStorageSync('supplierInfo', JSON.stringify(supplierInfo))
state.supplierInfo = supplierInfo
} catch (e) {
console.warn('更改supplierInfo失败:', e)
}
},
removeSupplierInfo(state) {
try {
uni.removeStorageSync('supplierInfo')
state.supplierInfo = {}
} catch (e) {
console.warn('删除supplierInfo失败:', e)
}
},
setNextPage(state, nextPage) {
if (!isObject(nextPage)) {
console.warn('nextPage必须是对象')
return
}
state.nextPage.name = nextPage.name || ''
state.nextPage.data = nextPage.data || {}
},
removeNextPage(state) {
state.nextPage.name = ''
state.nextPage.data = {}
},
setSearchHistory(state, searchHistory) {
if (!isArray(searchHistory)) {
console.warn('searchHistory必须是数组')
return
}
try {
uni.setStorageSync('searchHistory', JSON.stringify(searchHistory))
state.searchHistory = searchHistory
} catch (e) {
console.warn('更改searchHistory失败:', e)
}
},
clearSearchHistory(state) {
try {
uni.removeStorageSync('searchHistory')
state.searchHistory = []
} catch (e) {
console.warn('删除searchHistory失败:', e)
}
}
},
actions: {
logout({ commit }) {
commit('removeUecToken')
commit('removeToken')
commit('removeUserInfo')
commit('removeSupplierInfo')
},
addSearchHistory({ commit, state }, searchHistory) {
const arr = [...state.searchHistory] // 单层数组直接解构
let index = arr.findIndex((item) => item === searchHistory)
if (index > -1) {
arr.splice(index, 1)
}
arr.unshift(searchHistory)
if (arr.length > 10) {
arr = arr.slice(0, 10)
actions: {
logout({ commit }) {
console.log('logout')
commit('removeUecToken')
commit('removeToken')
commit('removeUserInfo')
commit('removeSupplierInfo')
},
addSearchHistory({ commit, state }, searchHistory) {
const arr = [...state.searchHistory] // 单层数组直接解构
let index = arr.findIndex((item) => item === searchHistory)
if (index > -1) {
arr.splice(index, 1)
}
arr.unshift(searchHistory)
if (arr.length > 10) {
arr = arr.slice(0, 10)
}
commit('setSearchHistory', arr)
}
commit('setSearchHistory', arr)
}
}
})
})
}
export default store

1
utils/hook.js

@ -75,6 +75,7 @@ export function go2(url, data = {}, isRedirect = false) {
*/
export function loginGo2(url, data = {}, isRedirect) {
const token = store.state.qnToken
console.log('token',token)
if (token) {
go2(url, data, isRedirect)
} else {

Loading…
Cancel
Save