Commit 28df12e8 by 李伟康

优化代码

1 parent ac5967b0
......@@ -2,7 +2,7 @@ import util from '@/utils/util'
import { Notify } from 'vant'
const url = '/rop-scrm-wechat/router'
const WxConfig = {
init(jsApiList) {
init (jsApiList) {
return new Promise((resolve, reject) => {
jsApiList.map(e => {
if (e == 'chooseImage') jsApiList.push('getLocalImgData')
......@@ -30,11 +30,11 @@ const WxConfig = {
nonceStr: obj.nonceStr, // 必填,生成签名的随机串
signature: obj.signature, // 必填,签名,见附录-JS-SDK使用权限签名算法,
jsApiList,
success(res) {
success (res) {
console.log(res, 'wx_config')
resolve()
},
fail(err) {
fail (err) {
console.log(err, 'wx_config')
reject(err)
}
......@@ -46,7 +46,7 @@ const WxConfig = {
})
},
/**生成小程序短链 */
createMiniprogramUrlLink(data = {}) {
createMiniprogramUrlLink (data = {}) {
const { envVersion } = window.$fetchConfig
data.method = 'scrm.api.wechat.miniprogram.geturllink'
data.envVersion = envVersion
......@@ -59,13 +59,13 @@ const WxConfig = {
* appId 微信应用ID
* envVersion 要打开的小程序版本。正式版为:release,体验版为:trial,开发版为:develop,仅在微信外打开时生效
*/
console.log('请求',data)
console.log('请求', data)
return window.$HTTP({
url,
data
})
},
getContext() {
getContext () {
/**
* entry String 场景值
* shareTicket String 仅当转发时设置了withShareTicket转发到会话的消息进入才返回该字段,详见私密消息
......@@ -96,7 +96,7 @@ const WxConfig = {
},
/**获取当前外部联系人userid */
getCurExternalContact() {
getCurExternalContact () {
return new Promise((resolve, reject) => {
wx.invoke('getCurExternalContact', {}, res => {
if (res.err_msg == 'getCurExternalContact:ok') {
......@@ -109,14 +109,18 @@ const WxConfig = {
},
/** 外部联系人选人接口 */
selectExternalContact() {
selectExternalContact (params = {
/**0表示展示全部外部联系人列表,
* 1表示仅展示未曾选择过的外部联系人。
* 默认值为0;除了0与1,
* 其他值非法。
* 在企业微信2.4.22及以后版本支持该参数
* */
filterType: 0
}) {
return new Promise(resolve => {
wx.invoke(
'selectExternalContact',
{
filterType: 0 //0表示展示全部外部联系人列表,1表示仅展示未曾选择过的外部联系人。默认值为0;除了0与1,其他值非法。在企业微信2.4.22及以后版本支持该参数
},
res => {
'selectExternalContact', params, res => {
if (res.err_msg == 'selectExternalContact:ok') {
resolve(res)
}
......@@ -126,14 +130,14 @@ const WxConfig = {
},
/**分享消息到当前会话 */
sendChatMessage(params) {
sendChatMessage (params) {
console.log(params)
return new Promise((resolve,reject) => {
return new Promise((resolve, reject) => {
wx.invoke('sendChatMessage', params, res => {
util.hideLoading()
if (res.err_msg == 'sendChatMessage:ok') {
resolve()
}else{
} else {
reject(res)
}
})
......@@ -141,7 +145,8 @@ const WxConfig = {
},
/**群发消息给客户 */
shareToExternalContact(params) {
shareToExternalContact (params) {
console.log(params)
return new Promise(resolve => {
wx.invoke('shareToExternalContact', params, res => {
if (res.err_msg == 'shareToExternalContact:ok') {
......@@ -152,7 +157,7 @@ const WxConfig = {
},
/**群发消息到客户群 */
shareToExternalChat(params) {
shareToExternalChat (params) {
return new Promise(resolve => {
wx.invoke('shareToExternalChat', params, res => {
if (res.err_msg == 'shareToExternalChat:ok') {
......@@ -163,12 +168,12 @@ const WxConfig = {
},
/**进入添加客户界面 */
navigateToAddCustomer() {
navigateToAddCustomer () {
wx.invoke('navigateToAddCustomer')
},
/**发表内容到客户朋友圈 */
shareToExternalMoments(params) {
shareToExternalMoments (params) {
return new Promise(resolve => {
wx.invoke('shareToExternalMoments', params, res => {
if (res.err_msg == 'shareToExternalMoments:ok') {
......@@ -179,7 +184,7 @@ const WxConfig = {
},
/**打开会话 */
openEnterpriseChat({ externalUserIds = [], groupName = '', userIds = [], chatId = '' }) {
openEnterpriseChat ({ externalUserIds = [], groupName = '', userIds = [], chatId = '' }) {
return new Promise(resolve => {
userIds = userIds.join(';')
externalUserIds = externalUserIds.join(';')
......@@ -189,10 +194,10 @@ const WxConfig = {
externalUserIds, // 参与会话的外部联系人列表,格式为userId1;userId2;…,用分号隔开。
groupName, // 会话名称。单聊时该参数传入空字符串""即可。
chatId, // 若要打开已有会话,需指定此参数。如果是新建会话,chatId必须为空串
success(res) {
success (res) {
resolve(res)
},
fail(res) {
fail (res) {
if (res.errMsg.indexOf('function not exist') > -1) {
Notify('版本过低请升级')
}
......@@ -202,13 +207,13 @@ const WxConfig = {
},
/**企业微信扫一扫 */
scanQRCode(needResult) {
scanQRCode (needResult) {
return new Promise(resolve => {
wx.scanQRCode({
desc: 'scanQRCode desc',
needResult, // 默认为0,扫描结果由企业微信处理,1则直接返回扫描结果,
scanType: ['qrCode', 'barCode'], // 可以指定扫二维码还是条形码(一维码),默认二者都有
success(res) {
success (res) {
resolve(res)
},
error: function (res) {
......@@ -221,14 +226,14 @@ const WxConfig = {
},
/**获取本地图片接口 */
getLocalImgData(localId) {
getLocalImgData (localId) {
return new Promise((resolve, reject) => {
wx.getLocalImgData({
localId, // 图片的
success(res) {
success (res) {
resolve(res) //localData是图片的base64数据,可以用img标签显示
},
fail(err) {
fail (err) {
reject(err)
}
})
......@@ -236,19 +241,19 @@ const WxConfig = {
},
/**拍照或从手机相册中选图接口 */
chooseImage(count = 1) {
chooseImage (count = 1) {
return new Promise(resolve => {
wx.chooseImage({
count, // 默认1
sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有
sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
success(res) {
success (res) {
let { localIds } = res
let imgs = []
localIds.map((e, index) => {
wx.getLocalImgData({
localId: e,
success(img) {
success (img) {
imgs.push(img)
if (index == localIds.length - 1) resolve(imgs)
}
......@@ -260,7 +265,7 @@ const WxConfig = {
},
/**预览图片接口 */
previewImage(obj) {
previewImage (obj) {
/**current 当前显示图片的http链接
* urls 需要预览的图片http链接列表
*/
......@@ -268,12 +273,12 @@ const WxConfig = {
},
/**上传图片接口 */
uploadImage(localId) {
uploadImage (localId) {
return new Promise(resolve => {
wx.uploadImage({
localId, // 需要上传的图片的本地ID,由chooseImage接口获得
isShowProgressTips: 1, // 默认为1,显示进度提示
success(res) {
success (res) {
resolve(res) // 返回图片的服务器端ID
/**备注:上传图片有效期3天,可用素材管理接口下载图片到自己的服务器,此处获得的 serverId 即 media_id。 */
}
......@@ -282,12 +287,12 @@ const WxConfig = {
},
/**下载图片接口 */
downloadImage(serverId) {
downloadImage (serverId) {
return new Promise(resolve => {
wx.downloadImage({
serverId, // 需要下载的图片的服务器端ID,由uploadImage接口获得
isShowProgressTips: 1, // 默认为1,显示进度提示
success(res) {
success (res) {
resolve(res) // 返回图片下载后的本地ID
}
})
......@@ -295,7 +300,7 @@ const WxConfig = {
},
/**使用企业微信内置地图查看位置接口 */
openLocation(obj) {
openLocation (obj) {
/**
latitude: 0, // 纬度,浮点数,范围为90 ~ -90
longitude: 0, // 经度,浮点数,范围为180 ~ -180。
......@@ -307,11 +312,11 @@ const WxConfig = {
},
/**获取地理位置接口 */
getLocation(type = 'wgs84') {
getLocation (type = 'wgs84') {
return new Promise(resolve => {
wx.getLocation({
type, // 默认为wgs84的gps坐标,如果要返回直接给openLocation用的火星坐标,可传入'gcj02'
success(res) {
success (res) {
resolve(res)
}
})
......@@ -319,7 +324,7 @@ const WxConfig = {
},
/**自定义转发到会话 */
shareAppMessage(obj) {
shareAppMessage (obj) {
// title: '', // 分享标题
// desc: '', // 分享描述
// link: '', // 分享链接
......@@ -336,7 +341,7 @@ const WxConfig = {
})
},
/**自定义转发到微信 */
shareWechatMessage(obj) {
shareWechatMessage (obj) {
// title: '', // 分享标题
// desc: '', // 分享描述
// link: '', // 分享链接
......
......@@ -237,6 +237,7 @@
box-sizing: border-box;
border-radius: 100%;
margin-right: 4px;
transition: all .2s;
}
.radio-active {
......@@ -244,16 +245,24 @@
display: flex;
justify-content: center;
align-items: center;
&::after {
content: '';
display: block;
width: 6px;
height: 6px;
background: #3975C6;
box-shadow: 0px 2px 6px 2px rgba(57, 117, 198, 0.11);
border: 1px solid #3975C6;
box-sizing: border-box;
border-radius: 100%;
animation: radioFrames .2s forwards;
}
}
@keyframes radioFrames {
0%{
width: 1px;
height: 1px;
}
100%{
width: 6px;
height: 6px;
}
}
\ No newline at end of file
......@@ -78,7 +78,7 @@
</div>
<div class="box readonly-box radio-box">
<div class="title">领取条件</div>
<template v-for="(i,index) in radioObj">
<template v-for="(i,index) in receiveWayObj">
<div
class="radio-item"
:key="index"
......@@ -145,8 +145,8 @@ export default {
receiveWay: 1,
couponList: []
},
radioObj: [
{ name: '指定手机号', type: 'tel', placeholder: '客户需输入指定的手机号,才能成功领取礼包', maxlength: 11, active: true, key: 'phone', value: 1 },
receiveWayObj: [
{ name: '指定手机号', type: 'tel', placeholder: '客户需输入指定的手机号,才能成功领取礼包', maxlength: 11, key: 'phone', value: 1 },
{ name: '指定车架号后6位', placeholder: '客户需输入指定的车架号,才能成功领取礼包', maxlength: 6, key: 'vin', value: 2 },
],
total: 0,
......@@ -187,12 +187,10 @@ export default {
return res
},
getDetail (id) {
let { radioObj } = this
giftApi.getGiftDetail(id).then(res => {
this.hideLoading()
res = this.setCouponData(res)
this.flag = true
radioObj.map(e => e.active = false)
if (res.receiveWay == 1) res.phone = res.receiveDetails
else res.vin = res.receiveDetails
this.obj = res
......@@ -200,9 +198,6 @@ export default {
})
},
changeRadio (index) {
let { radioObj } = this
radioObj.map(e => e.active = false)
radioObj[index].active = true
this.obj.receiveWay = index == 0 ? 1 : 2
this.checkData()
},
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!