登录、订单、客户

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. 64
      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. 104
      pages/orderDetail/orderDetail.vue
  12. 2
      pages/orders/orders.vue
  13. 13
      pages/plans/plans.vue

@ -3,4 +3,8 @@ const { get, post } = request
export const login = (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, {
token: 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ1c2VyIiwiaWF0IjoxNjU0MTM1MDg4LCJleHAiOjE2NTQxNzgyODgsImFjY291bnRJZCI6IjEifQ.wSb1OgO7vfJoRRNe9tHirTAiTd7vHQLsKFU58cQTe84'
// token: uni.getStorageSync('token')
token: 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ1c2VyIiwiaWF0IjoxNjU0MTYzMjI2LCJleHAiOjE2NTQyMDY0MjYsImFjY291bnRJZCI6IjQ1MiJ9.oqupeDUjOWMKjdj7p7TclcfnPbsZfqwra5QKxo2YqvU'
})
return new Promise((resolve, reject)=>{
const { url } = options
uni.request({
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
data: options.data || {}, // 请求参数,默认空对象
success: ({ data }) => {

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

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

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

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

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

@ -49,6 +49,12 @@
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
}).catch(e => {})
},

@ -29,7 +29,7 @@
</template>
<script>
import { login } from '@/apis/modules/user.js'
import { login, userBinding } from '@/apis/modules/user.js'
export default {
data() {
return {
@ -39,7 +39,10 @@
value: 1
}],
isLogin: true, //
getPhone: true //
getPhone: true ,//
sessionKey: '',
openId: '',
unionid: '',
}
},
onShow() {
@ -50,7 +53,7 @@
//
checkLogin() {
if (uni.getStorageSync('token')) {
this.$util.to('../index/index')
this.$util.to('../main/main')
} else {
this.isLogin = false
this.getPhone = false
@ -64,16 +67,23 @@
lang: 'zh_CN',
desc: '登录',
success: ({ userInfo }) => {
console.log(33, userInfo)
uni.setStorageSync('userName', userInfo.nickName)
uni.setStorageSync('avatar', userInfo.avatarUrl)
uni.login({
success: ({ code }) => {
if (code) {
this.isLogin = true
login({ code }).then(({ data }) => {
this.sessionKey = data.sessionKeyOpenId.session_key
// uni.setStorageSync('token', userInfo.avatarUrl)
const e = data.sessionKey
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 => {})
} else {
that.$util.errMsg('登录失败!')
@ -91,12 +101,19 @@
},
onGetPhoneNumber(e){
const { encryptedData, iv } = e.detail
//1.使js2.使
// 1.使js2.使
const WXBizDataCrypt = require('@/libs/WXBizDataCrypt')
const accountInfo = uni.getAccountInfoSync() // appid
const pc = new WXBizDataCrypt(accountInfo.miniProgram.appId , this.sessionKey)
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) {
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="line">
<view class="name">商务经理</view>
<view class="val"></view>
<view class="val">{{ $util.getBmName() }}</view>
</view>
<view class="line req">
<view class="name">客户名称</view>
@ -52,47 +52,49 @@
</view>
</view>
<view class="block pro-wrap" v-for="c in courseList">
<view class="l-title">{{ c.name }}</view>
<uni-icons class="arrow" type="top" size="20" color="#007EFF"></uni-icons>
<ul class="pro-list">
<li v-for="(item, i) in c.list">
<view class="name">
<view class="left">
<image class="icon" src="../../static/image/course1.png" mode=""></image>
{{ item.productName }}
<template v-for="c in courseList">
<view v-if="c.list.length" class="block pro-wrap">
<view class="l-title">{{ c.name }}</view>
<uni-icons class="arrow" type="top" size="20" color="#007EFF"></uni-icons>
<ul class="pro-list">
<li v-for="(item, i) in c.list">
<view class="name">
<view class="left">
<image v-if="item.miniProgramPictureAddress" class="icon" :src="item.miniProgramPictureAddress" mode="widthFix"></image>
{{ item.productName }}
</view>
<uni-icons v-if="!isDetail" class="del" type="trash" size="25" color="#ADADAD" @click="delCourse(c, i)"></uni-icons>
</view>
<uni-icons class="del" type="trash" size="25" color="#ADADAD" @click="delCourse(i)"></uni-icons>
</view>
<view class="info">
<view class="line">
<view class="label">使用期限</view>
<view class="val">{{ item.startTime + ' - ' + item.endTime }}</view>
</view>
<view class="line">
<view class="label">市场价</view>
<view class="val">{{ item.marketValue }}</view>
</view>
<view class="line">
<view class="label">结算价</view>
<view class="val">{{ item.settlementPrice }}</view>
</view>
<view class="line">
<view class="label">折扣率</view>
<view class="val">{{ item.discountRate }}</view>
<view class="info">
<view class="line">
<view class="label">使用期限</view>
<view class="val">{{ item.startTime + ' - ' + item.endTime }}</view>
</view>
<view class="line">
<view class="label">市场价</view>
<view class="val">{{ item.marketValue }}</view>
</view>
<view class="line">
<view class="label">结算价</view>
<view class="val">{{ item.settlementPrice }}</view>
</view>
<view class="line">
<view class="label">折扣率</view>
<view class="val">{{ item.discountRate }}</view>
</view>
<view class="line">
<view class="label">平台服务费</view>
<view class="val">{{ item.serviceFee }}</view>
</view>
<view class="line done">
<view class="val">成交价格</view>
<view class="price">{{ item.finalPrice }}</view>
</view>
</view>
<view class="line">
<view class="label">平台服务费</view>
<view class="val">{{ item.serviceFee }}</view>
</view>
<view class="line done">
<view class="val">成交价格</view>
<view class="price">{{ item.finalPrice }}</view>
</view>
</view>
</li>
</ul>
</view>
</li>
</ul>
</view>
</template>
<view class="bottom">
<view v-if="!orderId" class="add-btn" @click="toAdd">
@ -114,7 +116,7 @@
总采购成本:
<text class="num num1">{{ purchase }}</text>
总产品利润:
<text class="num">{{ profit }}</text>
<text class="num"> {{ profit }}</text>
</view>
</view>
<view v-if="!isDetail" class="btn" @click="submit">提交</view>
@ -151,16 +153,18 @@
form: {
// orderNumber: '', //
provinceId: '', // id
provinceName: '',
orderContact: '', //
email: '',
customerId: '', // id
customerName: '',
orderType: '',
cityId: '',
cityName: '',
phone: '',
orderAmount: 0,
customerName: '',
businessManager: ''
businessManagerId: this.$util.getBmId()
},
courseList: {},
courses: [], //
@ -216,8 +220,7 @@
//
getInfo() {
getDetail({
// orderId: this.orderId
orderId: 121
orderId: this.orderId
}).then(({ orderDetails }) => {
const order = orderDetails
this.contract = order.contractInformation
@ -246,6 +249,7 @@
console.log(111, list)
// 3push(0-> 1- 2 )
list.map(e => {
e.serviceFee = (e.settlementPrice * 0.1).toFixed(2)
const type = e.productType
!type ?
courses.theory.list.push(e) :
@ -253,10 +257,6 @@
courses.practice.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)
this.courseList = courses
},
@ -296,6 +296,10 @@
const e = result.customer
form.customerId = e.customerId
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.email = e.email
form.name = e.name
@ -311,13 +315,13 @@
this.$util.errMsg('请先选择客户!')
},
//
delCourse(i) {
delCourse(c, i) {
const that = this
uni.showModal({
title: '提示',
content: '确定要删除吗?',
success(res) {
res.confirm && that.courses.splice(i, 1)
res.confirm && c.list.splice(i, 1)
}
})
},

@ -138,7 +138,7 @@
methods: {
getList() {
list({
businessManagerId: 111,
businessManagerId: this.$util.getBmId(),
keywords: this.keyword,
pageNum: this.page,
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>
</ul>
<ul class="list">
<ul v-if="list.length" class="list">
<li v-for="(item, i) in list">
<view class="name">{{ item.name }}</view>
<view class="content">
@ -31,6 +31,7 @@
</view>
</li>
</ul>
<empty v-else></empty>
</view>
</template>
@ -38,11 +39,11 @@
export default {
data() {
return {
curTab: 0,
curTab: '',
tabs: [
{
name: '不限',
id: 0
id: ''
},
{
name: '标准方案',
@ -117,8 +118,10 @@
},
// tab
tabChange(tab) {
this.curTab = tab.id
this.list = this.all.filter(e => e.type === tab.id)
const { id } = tab
const { all } = this
this.curTab = id
this.list = id ? all.filter(e => e.type === id) : all
},
//
toDetail(id) {

Loading…
Cancel
Save