登录、订单、客户

master
yujialong 3 years ago
parent 323c52a972
commit 8de4d1fa7a
  1. 4
      apis/modules/user.js
  2. 5
      apis/request.js
  3. 10
      libs/util.js
  4. 9
      pages.json
  5. 56
      pages/addCourse/addCourse.vue
  6. 2
      pages/clients/clients.vue
  7. 46
      pages/editCourse/editCourse.vue
  8. 6
      pages/index/index.vue
  9. 35
      pages/login/login.vue
  10. 97
      pages/main/main.vue
  11. 32
      pages/orderDetail/orderDetail.vue
  12. 2
      pages/orders/orders.vue
  13. 13
      pages/plans/plans.vue

@ -4,3 +4,7 @@ const { get, post } = request
export const login = (data) => { export const login = (data) => {
return get('users/users/user/weChatAppletCallback', data) return get('users/users/user/weChatAppletCallback', data)
} }
export const userBinding = (data) => {
return post('users/users/user/userBinding', data)
}

@ -12,13 +12,14 @@ const request = options => {
}) })
} }
const header = Object.assign({}, config.headers, { const header = Object.assign({}, config.headers, {
token: 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ1c2VyIiwiaWF0IjoxNjU0MTM1MDg4LCJleHAiOjE2NTQxNzgyODgsImFjY291bnRJZCI6IjEifQ.wSb1OgO7vfJoRRNe9tHirTAiTd7vHQLsKFU58cQTe84' // token: uni.getStorageSync('token')
token: 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ1c2VyIiwiaWF0IjoxNjU0MTYzMjI2LCJleHAiOjE2NTQyMDY0MjYsImFjY291bnRJZCI6IjQ1MiJ9.oqupeDUjOWMKjdj7p7TclcfnPbsZfqwra5QKxo2YqvU'
}) })
return new Promise((resolve, reject)=>{ return new Promise((resolve, reject)=>{
const { url } = options const { url } = options
uni.request({ uni.request({
header, header,
url: (url.includes('weChatAppletCallback') ? 'http://192.168.31.137:9000/' : config.baseURL) + url, url: ((url.includes('weChatAppletCallback') || url.includes('userBinding')) ? 'http://192.168.31.137:9000/' : config.baseURL) + url,
method: options.method || 'GET', // 请求类型,默认为GET method: options.method || 'GET', // 请求类型,默认为GET
data: options.data || {}, // 请求参数,默认空对象 data: options.data || {}, // 请求参数,默认空对象
success: ({ data }) => { success: ({ data }) => {

@ -43,5 +43,13 @@ export default {
} }
} }
return fmt return fmt
} },
// 获取商务经理id
getBmId(val) {
return uni.getStorageSync('partnerId')
},
// 获取商务经理名称
getBmName(val) {
return uni.getStorageSync('partnerClassificationName')
},
} }

@ -158,6 +158,15 @@
"enablePullDownRefresh": false "enablePullDownRefresh": false
} }
} }
,{
"path" : "pages/main/main",
"style" :
{
"navigationBarTitleText": "",
"enablePullDownRefresh": false
}
}
], ],
"condition": { // "condition": { //
"current": 0, //list "current": 0, //list

@ -90,7 +90,6 @@
}, },
// //
onReachBottom() { onReachBottom() {
console.log(4444)
if (this.reachBottom >= 0) { if (this.reachBottom >= 0) {
this.reachBottom = 1 this.reachBottom = 1
this.status = 'loading' this.status = 'loading'
@ -174,6 +173,7 @@
authority: e.productType === 2 ? 0 : 1, // 01 authority: e.productType === 2 ? 0 : 1, // 01
productType: e.productType, // (0-> 1- 2 ) productType: e.productType, // (0-> 1- 2 )
options: 1, options: 1,
miniProgramPictureAddress: e.miniProgramPictureAddress, //
settlementPrice: '', // settlementPrice: '', //
settlementMethod: e.settlementMethod, // 01 settlementMethod: e.settlementMethod, // 01
settlementPriceUnit: e.settlementPrice, // settlementPriceUnit: e.settlementPrice, //
@ -181,39 +181,55 @@
serviceFee: 0 // serviceFee: 0 //
} }
}, },
//
submit() {
const list = this.list.filter(e => e.check.length) //
if (list.length) {
const result = this.courses
const courseIds = []
const dataIds = []
const { customerId } = this
list.map(e => {
// e.authority ? courseIds.push(e.cid) : dataIds.push(e.cid)
courseIds.push(e.cid)
result.find(n => n.dataOrCourseId == e.cid) || result.push(this.createParam(e))
})
// //
handleRenew(authority, customerId, productId, result, resolve, reject) {
renew({ renew({
authority: 1, authority,
customerId, customerId,
productId: courseIds productId
}).then(({ orderOthers }) => { }).then(({ orderOthers }) => {
result.map(e => { result.map(e => {
// const item = orderOthers.map(n => dataOrCourseId == e.dataOrCourseId && n.authority && e.authority) const item = orderOthers.find(n => n.dataOrCourseId == e.dataOrCourseId && n.authority == authority && e.authority == authority)
const item = orderOthers.find(n => n.dataOrCourseId == e.dataOrCourseId)
if (item) { if (item) {
let date = new Date(item.endTime) let date = new Date(item.endTime)
date = new Date(date.setDate(date.getDate() + 1)) date = new Date(date.setDate(date.getDate() + 1))
e.startTime = this.$util.formatDate(date, 'yyyy-MM-dd') e.startTime = this.$util.formatDate(date, 'yyyy-MM-dd')
} }
}) })
resolve()
}).catch(e => {
reject()
})
},
//
submit() {
const list = this.list.filter(e => e.check.length) //
if (list.length) {
const result = this.courses
const courseIds = []
const dataIds = []
const { customerId } = this
list.map(e => {
// id
if (!result.find(n => n.dataOrCourseId == e.id)) {
e.productType === 2 ? dataIds.push(e.id) : courseIds.push(e.id)
result.push(this.createParam(e))
}
})
const promises = []
dataIds.length && promises.push(new Promise((resolve, reject) => {
this.handleRenew(0, customerId, dataIds, result, resolve, reject)
}))
courseIds.length && promises.push(new Promise((resolve, reject) => {
this.handleRenew(1, customerId, courseIds, result, resolve, reject)
}))
Promise.all(promises).then(_ => {
uni.setStorageSync('courses', result) // uni.setStorageSync('courses', result) //
uni.redirectTo({ uni.redirectTo({
url: `../editCourse/editCourse?customerId=${this.customerId}` url: `../editCourse/editCourse?customerId=${customerId}`
})
}) })
}).catch(e => {})
} else { } else {
this.$util.errMsg('请选择产品!') this.$util.errMsg('请选择产品!')
} }

@ -118,7 +118,7 @@
getList() { getList() {
const method = this.curTab ? all : list const method = this.curTab ? all : list
method({ method({
businessManagerId: 112, businessManagerId: this.$util.getBmId(),
customerType: this.customerType, customerType: this.customerType,
keywords: this.keyword, keywords: this.keyword,
pageNum: this.page, pageNum: this.page,

@ -6,7 +6,7 @@
<view v-for="(item, i) in courses"> <view v-for="(item, i) in courses">
<view class="pro-name"> <view class="pro-name">
<view class="left"> <view class="left">
<image class="icon" src="../../static/image/course1.png" mode=""></image> <image v-if="item.miniProgramPictureAddress" class="icon" :src="item.miniProgramPictureAddress" mode="widthFix"></image>
{{ item.productName }} {{ item.productName }}
</view> </view>
<uni-icons class="del" type="trash" size="25" color="#ADADAD" @click="delCourse(i)"></uni-icons> <uni-icons class="del" type="trash" size="25" color="#ADADAD" @click="delCourse(i)"></uni-icons>
@ -85,7 +85,7 @@
text: '年', text: '年',
value: 2 value: 2
}], }],
courses: uni.getStorageSync('courses'), // courses: [], //
orderRepeat: [], orderRepeat: [],
repeatMsg: '' repeatMsg: ''
} }
@ -94,6 +94,13 @@
const pages = getCurrentPages() const pages = getCurrentPages()
const { options } = pages[pages.length - 1] const { options } = pages[pages.length - 1]
this.customerId = options.customerId this.customerId = options.customerId
const store = uni.getStorageSync('courses')
if (store) {
this.courses = store
try {
uni.removeStorageSync('courses')
} catch (e) {}
}
}, },
methods: { methods: {
// //
@ -195,32 +202,37 @@
calcDiscount(row) { calcDiscount(row) {
const price = row.authority ? row.finalPrice : row.finalValue const price = row.authority ? row.finalPrice : row.finalValue
const { marketValue } = row const { marketValue } = row
// // // (-)÷ x100%
if (price) row.discountRate = marketValue != 0 ? (price / row.marketValue * 100).toFixed(2) + '%' : '0%' if (price) row.discountRate = marketValue != 0 ? ((marketValue - price) / marketValue * 100).toFixed(2) + '%' : '0%'
}, },
// //// // ////
calcFinalValue(row) { calcFinalValue(row) {
const { authority, periodOfUse, options, accountNum, finalPrice } = row const { authority, periodOfUse, options, accountNum, finalPrice } = row
if (authority && periodOfUse && accountNum && finalPrice) { if (!authority && periodOfUse && accountNum && finalPrice) {
row.finalValue = (finalPrice / accountNum / periodOfUse * (!options ? row.finalValue = (finalPrice / accountNum / periodOfUse).toFixed(2)
365 :
options === 1 ?
12 :
1)).toFixed(2)
} }
// //
this.calcDiscount(row) this.calcDiscount(row)
}, },
// **// // **//
calcFinalPrice(row) { calcFinalPrice(row) {
const { finalValue, accountNum, periodOfUse, options } = row const { finalValue, accountNum, periodOfUse, finalPrice } = row
if (finalValue && accountNum) { if (periodOfUse) {
row.finalPrice = ((!options ? if (accountNum) {
finalValue / 365 * periodOfUse : // =**
options === 1 ? if (finalValue) {
finalValue / 12 * periodOfUse : row.finalPrice = Math.round(finalValue * periodOfUse * accountNum)
finalValue * periodOfUse) * accountNum).toFixed(2) } else if (!finalValue && finalPrice) {
// =//
row.finalValue = (finalPrice / periodOfUse / accountNum).toFixed(2)
this.calculateDiscount(e, row)
}
} else if (finalValue && finalValue && !row.authority) {
// =//
row.accountNum = Math.floor(finalPrice / periodOfUse / finalValue)
} }
}
this.dealSettlePrice(row)
}, },
// //
submit() { submit() {

@ -49,6 +49,12 @@
value: e.partnerId value: e.partnerId
}) })
}) })
console.log(22, result)
if (result.length === 1) {
const val = result[0].value
this.partnerId = val
uni.setStorageSync('partnerId', val)
}
this.list = result this.list = result
}).catch(e => {}) }).catch(e => {})
}, },

@ -29,7 +29,7 @@
</template> </template>
<script> <script>
import { login } from '@/apis/modules/user.js' import { login, userBinding } from '@/apis/modules/user.js'
export default { export default {
data() { data() {
return { return {
@ -39,7 +39,10 @@
value: 1 value: 1
}], }],
isLogin: true, // isLogin: true, //
getPhone: true // getPhone: true ,//
sessionKey: '',
openId: '',
unionid: '',
} }
}, },
onShow() { onShow() {
@ -50,7 +53,7 @@
// //
checkLogin() { checkLogin() {
if (uni.getStorageSync('token')) { if (uni.getStorageSync('token')) {
this.$util.to('../index/index') this.$util.to('../main/main')
} else { } else {
this.isLogin = false this.isLogin = false
this.getPhone = false this.getPhone = false
@ -64,16 +67,23 @@
lang: 'zh_CN', lang: 'zh_CN',
desc: '登录', desc: '登录',
success: ({ userInfo }) => { success: ({ userInfo }) => {
console.log(33, userInfo)
uni.setStorageSync('userName', userInfo.nickName) uni.setStorageSync('userName', userInfo.nickName)
uni.setStorageSync('avatar', userInfo.avatarUrl) uni.setStorageSync('avatar', userInfo.avatarUrl)
uni.login({ uni.login({
success: ({ code }) => { success: ({ code }) => {
if (code) { if (code) {
this.isLogin = true
login({ code }).then(({ data }) => { login({ code }).then(({ data }) => {
this.sessionKey = data.sessionKeyOpenId.session_key const e = data.sessionKey
// uni.setStorageSync('token', userInfo.avatarUrl) this.sessionKey = e.session_key
this.openId = e.openid
this.unionid = e.unionid
uni.setStorageSync('sessionKey', e.session_key)
if (data.state === 'login') {
this.$util.to('../main/main')
uni.setStorageSync('token', data.token)
} else {
this.isLogin = true
}
}).catch(e => {}) }).catch(e => {})
} else { } else {
that.$util.errMsg('登录失败!') that.$util.errMsg('登录失败!')
@ -91,12 +101,19 @@
}, },
onGetPhoneNumber(e){ onGetPhoneNumber(e){
const { encryptedData, iv } = e.detail const { encryptedData, iv } = e.detail
//1.使js2.使 // 1.使js2.使
const WXBizDataCrypt = require('@/libs/WXBizDataCrypt') const WXBizDataCrypt = require('@/libs/WXBizDataCrypt')
const accountInfo = uni.getAccountInfoSync() // appid const accountInfo = uni.getAccountInfoSync() // appid
const pc = new WXBizDataCrypt(accountInfo.miniProgram.appId , this.sessionKey) const pc = new WXBizDataCrypt(accountInfo.miniProgram.appId , this.sessionKey)
const data = pc.decryptData(encryptedData , iv) const data = pc.decryptData(encryptedData , iv)
console.log(222, data) userBinding({
openId: this.openId,
phone: data.phoneNumber,
unionid: this.unionid
}).then(({ token }) => {
uni.setStorageSync('token', token)
this.$util.to('../main/main')
}).catch(e => {})
}, },
toAgreement(id) { toAgreement(id) {
this.$util.to('../detail/detail?id=' + id) this.$util.to('../detail/detail?id=' + id)

@ -0,0 +1,97 @@
<template>
<view class="page">
<view class="team">
<uni-data-picker class="picker-input" placeholder="切换团队" popup-title="切换团队" preload :clear-icon="false" :localdata="list" v-model="partnerId" @change="teamChange"></uni-data-picker>
</view>
<image class="banner" src="../../static/image/index/index1.png" mode="widthFix"></image>
<ul class="entry">
<li @click="$util.to('../clients/clients')">
<image class="icon" src="../../static/image/index/index3.png" mode="widthFix"></image>
<view class="text">客户</view>
</li>
<li @click="$util.to('../plans/plans')">
<image class="icon" src="../../static/image/index/index4.png" mode="widthFix"></image>
<view class="text">方案</view>
</li>
<li @click="$util.to('../orders/orders')">
<image class="icon" src="../../static/image/index/index5.png" mode="widthFix"></image>
<view class="text">订单</view>
</li>
<li @click="$util.to('../products/products')">
<image class="icon" src="../../static/image/index/index6.png" mode="widthFix"></image>
<view class="text">产品</view>
</li>
</ul>
</view>
</template>
<script>
import { getTeamsByAccountId } from '@/apis/modules/client.js'
export default {
data() {
return {
partnerId: this.$util.getBmId() || '',
list: [],
}
},
onShow() {
this.getInfo()
},
methods: {
//
getInfo() {
getTeamsByAccountId().then(({ data }) => {
const result = []
data.map(e => {
result.push({
text: e.partnerClassificationName,
value: e.partnerId
})
})
//
if (result.length) {
const val = result[0].value
this.partnerId = val
uni.setStorageSync('partnerId', val)
uni.setStorageSync('partnerClassificationName', result[0].text)
}
this.list = result
}).catch(e => {})
},
//
teamChange() {
uni.setStorageSync('partnerId', this.partnerId)
}
}
}
</script>
<style scoped lang="scss">
.page {
min-height: 100%;
padding: 30rpx 22rpx;
background: url(../../static/image/index/index2.png) 0 0/100% 100% no-repeat;
}
.team {
width: 200rpx;
margin-bottom: 30rpx;
}
.banner {
width: 100%;
}
.entry {
display: flex;
justify-content: space-around;
align-items: center;
margin-top: 10rpx;
text-align: center;
.icon {
width: 78rpx;
}
.text {
font-size: 28rpx;
color: #333;
}
}
</style>

@ -5,7 +5,7 @@
<view class="form-list"> <view class="form-list">
<view class="line"> <view class="line">
<view class="name">商务经理</view> <view class="name">商务经理</view>
<view class="val"></view> <view class="val">{{ $util.getBmName() }}</view>
</view> </view>
<view class="line req"> <view class="line req">
<view class="name">客户名称</view> <view class="name">客户名称</view>
@ -52,17 +52,18 @@
</view> </view>
</view> </view>
<view class="block pro-wrap" v-for="c in courseList"> <template v-for="c in courseList">
<view v-if="c.list.length" class="block pro-wrap">
<view class="l-title">{{ c.name }}</view> <view class="l-title">{{ c.name }}</view>
<uni-icons class="arrow" type="top" size="20" color="#007EFF"></uni-icons> <uni-icons class="arrow" type="top" size="20" color="#007EFF"></uni-icons>
<ul class="pro-list"> <ul class="pro-list">
<li v-for="(item, i) in c.list"> <li v-for="(item, i) in c.list">
<view class="name"> <view class="name">
<view class="left"> <view class="left">
<image class="icon" src="../../static/image/course1.png" mode=""></image> <image v-if="item.miniProgramPictureAddress" class="icon" :src="item.miniProgramPictureAddress" mode="widthFix"></image>
{{ item.productName }} {{ item.productName }}
</view> </view>
<uni-icons class="del" type="trash" size="25" color="#ADADAD" @click="delCourse(i)"></uni-icons> <uni-icons v-if="!isDetail" class="del" type="trash" size="25" color="#ADADAD" @click="delCourse(c, i)"></uni-icons>
</view> </view>
<view class="info"> <view class="info">
<view class="line"> <view class="line">
@ -93,6 +94,7 @@
</li> </li>
</ul> </ul>
</view> </view>
</template>
<view class="bottom"> <view class="bottom">
<view v-if="!orderId" class="add-btn" @click="toAdd"> <view v-if="!orderId" class="add-btn" @click="toAdd">
@ -114,7 +116,7 @@
总采购成本: 总采购成本:
<text class="num num1">{{ purchase }}</text> <text class="num num1">{{ purchase }}</text>
总产品利润: 总产品利润:
<text class="num">{{ profit }}</text> <text class="num"> {{ profit }}</text>
</view> </view>
</view> </view>
<view v-if="!isDetail" class="btn" @click="submit">提交</view> <view v-if="!isDetail" class="btn" @click="submit">提交</view>
@ -151,16 +153,18 @@
form: { form: {
// orderNumber: '', // // orderNumber: '', //
provinceId: '', // id provinceId: '', // id
provinceName: '',
orderContact: '', // orderContact: '', //
email: '', email: '',
customerId: '', // id customerId: '', // id
customerName: '', customerName: '',
orderType: '', orderType: '',
cityId: '', cityId: '',
cityName: '',
phone: '', phone: '',
orderAmount: 0, orderAmount: 0,
customerName: '', customerName: '',
businessManager: '' businessManagerId: this.$util.getBmId()
}, },
courseList: {}, courseList: {},
courses: [], // courses: [], //
@ -216,8 +220,7 @@
// //
getInfo() { getInfo() {
getDetail({ getDetail({
// orderId: this.orderId orderId: this.orderId
orderId: 121
}).then(({ orderDetails }) => { }).then(({ orderDetails }) => {
const order = orderDetails const order = orderDetails
this.contract = order.contractInformation this.contract = order.contractInformation
@ -246,6 +249,7 @@
console.log(111, list) console.log(111, list)
// 3push(0-> 1- 2 ) // 3push(0-> 1- 2 )
list.map(e => { list.map(e => {
e.serviceFee = (e.settlementPrice * 0.1).toFixed(2)
const type = e.productType const type = e.productType
!type ? !type ?
courses.theory.list.push(e) : courses.theory.list.push(e) :
@ -253,10 +257,6 @@
courses.practice.list.push(e) : courses.practice.list.push(e) :
courses.data.list.push(e) courses.data.list.push(e)
}) })
//
courses.practice.list.length || delete courses.practice
courses.theory.list.length || delete courses.theory
courses.data.list.length || delete courses.data
console.log(222, courses) console.log(222, courses)
this.courseList = courses this.courseList = courses
}, },
@ -296,6 +296,10 @@
const e = result.customer const e = result.customer
form.customerId = e.customerId form.customerId = e.customerId
form.customerName = e.customerName form.customerName = e.customerName
form.provinceId = e.provinceId
form.cityId = e.cityId
form.provinceName = e.provinceName
form.cityName = e.cityName
form.phone = e.phone form.phone = e.phone
form.email = e.email form.email = e.email
form.name = e.name form.name = e.name
@ -311,13 +315,13 @@
this.$util.errMsg('请先选择客户!') this.$util.errMsg('请先选择客户!')
}, },
// //
delCourse(i) { delCourse(c, i) {
const that = this const that = this
uni.showModal({ uni.showModal({
title: '提示', title: '提示',
content: '确定要删除吗?', content: '确定要删除吗?',
success(res) { success(res) {
res.confirm && that.courses.splice(i, 1) res.confirm && c.list.splice(i, 1)
} }
}) })
}, },

@ -138,7 +138,7 @@
methods: { methods: {
getList() { getList() {
list({ list({
businessManagerId: 111, businessManagerId: this.$util.getBmId(),
keywords: this.keyword, keywords: this.keyword,
pageNum: this.page, pageNum: this.page,
pageSize: this.pageSize, pageSize: this.pageSize,

@ -9,7 +9,7 @@
<li v-for="(tab, i) in tabs" :class="{active: curTab === tab.id}" @click="tabChange(tab)">{{ tab.name }}</li> <li v-for="(tab, i) in tabs" :class="{active: curTab === tab.id}" @click="tabChange(tab)">{{ tab.name }}</li>
</ul> </ul>
<ul class="list"> <ul v-if="list.length" class="list">
<li v-for="(item, i) in list"> <li v-for="(item, i) in list">
<view class="name">{{ item.name }}</view> <view class="name">{{ item.name }}</view>
<view class="content"> <view class="content">
@ -31,6 +31,7 @@
</view> </view>
</li> </li>
</ul> </ul>
<empty v-else></empty>
</view> </view>
</template> </template>
@ -38,11 +39,11 @@
export default { export default {
data() { data() {
return { return {
curTab: 0, curTab: '',
tabs: [ tabs: [
{ {
name: '不限', name: '不限',
id: 0 id: ''
}, },
{ {
name: '标准方案', name: '标准方案',
@ -117,8 +118,10 @@
}, },
// tab // tab
tabChange(tab) { tabChange(tab) {
this.curTab = tab.id const { id } = tab
this.list = this.all.filter(e => e.type === tab.id) const { all } = this
this.curTab = id
this.list = id ? all.filter(e => e.type === id) : all
}, },
// //
toDetail(id) { toDetail(id) {

Loading…
Cancel
Save