付延余
2023-03-23 1cb780b1762c62751c7f5f26132f3a7aa4ef3e2f
微信登录修改,呼叫客服功能(完成)
12个文件已修改
241 ■■■■■ 已修改文件
api/globalApi.js 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/publicInterface.js 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/request.js 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages.json 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/driver-page/appointment/appointment.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/driver-page/driver-index/bill-of-lading-details/bill-of-lading-details.vue 133 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/driver-page/driver-index/bill-of-lading-details/weighingDevice/weighingDevice.vue 20 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/login/login.vue 39 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/login/userPassword.vue 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/tabbar-page/index-tabbar/index-tabbar.vue 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
utils/status.config.js 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
utils/status.js 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/globalApi.js
@@ -262,5 +262,11 @@
    coalDayPage: {
        url: "/wrzs/tmtaskcoallog/getTmId",
        method: 'GET'
    },
    // 获取openId
    getCallOutList:{
        url:'/wrzs/callout/getCallOutList',
        method:'GET'
    }
}
api/publicInterface.js
@@ -4,7 +4,7 @@
// const BaseUrl = "http://192.168.3.159:9999/";
import {BaseUrl as wrBaseUrl} from '@/api/request.js'
// const BaseUrl = "http://192.168.0.120:9999"
const BaseUrl = "http://192.168.110.82:9999"
const BaseUrl = "http://192.168.3.109:9999"
// 登录
// function apiLogin({
api/request.js
@@ -80,8 +80,8 @@
// const BaseUrl = "http://192.168.0.120:9997"
// const webSocketUrl = "ws://192.168.0.120:9997/wrzs/ws/info"
const BaseUrl = "http://192.168.110.82:9997";
const webSocketUrl = "ws://192.168.110.82:9997/wrzs/ws/info"
const BaseUrl = "http://192.168.3.109:9997";
const webSocketUrl = "ws://192.168.3.109:9997/wrzs/ws/info"
// 请求拦截
const fetch = (url, opt) => {
pages.json
@@ -115,7 +115,7 @@
        }, {
            "path": "pages/driver-page/appointment/appointment",
            "style": {
                "navigationBarTitleText": "预约",
                "navigationBarTitleText": "时段",
                "enablePullDownRefresh": false
            }
pages/driver-page/appointment/appointment.vue
@@ -13,7 +13,7 @@
                    <uni-td align="center">{{ (item.startTime || '') + '-' + (item.endTime || '') }}</uni-td>
                    <uni-td align="center">{{ item.carNum || '' }}</uni-td>
                    <uni-td align="center">{{ item.carNum1 || '' }}</uni-td>
                    <uni-td><u-button text="预约" type="primary" :disabled="item.carNum == item.carNum1" @click="yuYueBtnClick(item)"></u-button></uni-td>
                    <uni-td><u-button text="选择" type="primary" :disabled="item.carNum == item.carNum1" @click="yuYueBtnClick(item)"></u-button></uni-td>
                </uni-tr>
            </uni-table>
        </view>
pages/driver-page/driver-index/bill-of-lading-details/bill-of-lading-details.vue
@@ -2,32 +2,34 @@
    <view class="bill-of-lading-details">
        <view class="bangDanMessage">
            <view class="">
                <u--text align="center" size="35" bold plain text="主色" :text="'客户:' + coalDetailsData.customerName"></u--text>
                <u--text align="center" size="35" bold plain text="主色" :text="'矿厂:' + coalDetailsData.deptName"></u--text>
                <text>客户:{{ coalDetailsData.customerName }}</text>
                <text>矿厂:{{ coalDetailsData.deptName }}</text>
            </view>
            <view class="">
                <u--text align="center" size="35" bold plain text="主色" :text="'皮重:' + coalDetailsData.skin"></u--text>
                <u--text align="center" size="35" bold plain text="主色" :text="'毛重:' + coalDetailsData.hair"></u--text>
                <u--text align="center" size="35" bold plain text="主色" :text="'净重:' + coalDetailsData.clean"></u--text>
                <text>皮重:{{ coalDetailsData.skin }}</text>
                <text>毛重:{{ coalDetailsData.hair }}</text>
                <text>净重:{{ coalDetailsData.clean }}</text>
            </view>
            <view class="">
                <u--text align="center" size="35" bold plain text="主色" :text="'磅单类型:' + coalDetailsData.orderTye"></u--text>
                <u--text align="center" size="35" bold plain text="主色" :text="'状态:' + coalStatus[coalDetailsData.status]"></u--text>
                <text>磅单类型:{{ coalDetailsData.orderTye }}</text>
                <text>状态:{{ coalStatus[coalDetailsData.status] }}</text>
            </view>
            <u--text align="center" size="35" bold plain text="主色" :text="'煤场:' + coalDetailsData.filedName"></u--text>
            <u--text align="center" size="35" bold plain text="主色" :text="'发运时间:' + coalDetailsData.sendDate"></u--text>
            <u--text align="center" size="35" bold plain text="主色" :text="'提煤单编号:' + coalDetailsData.code"></u--text>
            <u--text align="center" size="35" bold plain text="主色" :text="'订单编号:' + coalDetailsData.orderCode"></u--text>
            <view class="">
                <text>煤场:{{ coalDetailsData.filedName }}</text>
                <text>发运时间:{{ coalDetailsData.sendDate }}</text>
                <text>提煤单编号:{{ coalDetailsData.code }}</text>
                <text>订单编号:{{ coalDetailsData.orderCode }}</text>
            </view>
        </view>
        <view class="timeLine" style="font-size: 16rpx;">
            <u--text type="primary" size="30" plain text="主色" v-for="(item, index) in dayRZ" :key="index" :text="item.taskStatusDes"></u--text>
            <u--text type="primary" size="30" plain v-for="(item, index) in dayRZ" :key="index" :text="item.taskStatusDes"></u--text>
        </view>
        <view class="utilsBox">
            <view class="utils_chil utils_chilTop">
                <u-button text="签到" type="primary" plain @click="arriveClick"></u-button>
                <u-button text="入场申请" type="primary" plain @click="rcsqClick"></u-button>
                <u-button text="放空" type="primary" plain></u-button>
                <u-button text="呼叫客服" type="primary" plain></u-button>
                <u-button text="呼叫客服" type="primary" plain @click="callCustomerService"></u-button>
            </view>
            <view class="utils_chil"><u-button text="展示提煤单" @click="showCaolPickUpBill" type="primary"></u-button></view>
            <view class="utils_chil"><u-button text="上磅计量" @click="cengZhongClick" type="primary"></u-button></view>
@@ -38,11 +40,11 @@
<script>
export default {
    onLoad(value) {
        console.log('页面加载', value);
        if (value.orderPlanId && value.yyId) {
            this.orderPlanId = value.orderPlanId;
            this.yyId = value.yyId;
        }
        // wx.startRecord();
    },
    data() {
        return {
@@ -50,18 +52,29 @@
            yyId: null,
            dayRZ: [],
            coalDetailsData: {}, // 提煤单详情
            // 获取所在磅房参数
            getWeightHouseObj: {
                // 获取所在磅房
                deptId: '',
                filedId: '',
                tmId: '',
                tmCode: '',
                carNo: ''
            },
            // 获取入场申请的列表页面参数
            getYuYueDataParams: {
                deptId: '',
                filedId: '',
                sendDate: ''
            },
            // 获取客服openid参数
            getServiceOpenid: {
                deptId: '',
                filedId: ''
            },
            // 客服信息
            serviceInfoObj: {
                openId: null,
                openName: ''
            },
            coalStatus: ['领取', '预约', '签到', '入场', '称皮', '称毛', '离场', '入磅房', '出磅房', '入煤场', '出煤仓'] // 状态
        };
@@ -70,8 +83,8 @@
        this.init();
    },
    computed: {
        userName() {
            return uni.getStorageSync('username');
        name() {
            return uni.getStorageSync('name');
        },
        openid() {
            return uni.getStorageSync('openid');
@@ -79,8 +92,23 @@
    },
    methods: {
        init() {
            this.coalDayPage();
            this.getTakeCoal();
            this.coalDayPage(); //获取日志
            this.getTakeCoal(); //获取提煤单详情
            this.getgetService(); //获取客服
        },
        // 获取客服openid
        getgetService() {
            this.$reqGet('getCallOutList', this.getServiceOpenid).then(res => {
                console.log(res, '客服openid');
                if (res.code != 0) {
                    this.$u.toast('获取客服信息失败');
                } else {
                    if (res.data.length > 0) {
                        this.serviceInfoObj.openId = res.data[0].openId;
                        this.serviceInfoObj.openName = res.data[0].openName;
                    }
                }
            });
        },
        // 获取提煤单详情
        getTakeCoal() {
@@ -97,6 +125,9 @@
                    this.getYuYueDataParams.deptId = this.coalDetailsData.deptId;
                    this.getYuYueDataParams.filedId = this.coalDetailsData.filedId;
                    this.getYuYueDataParams.sendDate = this.coalDetailsData.sendDate;
                    // 获取客服openId参数赋值
                    this.getServiceOpenid.deptId = this.coalDetailsData.deptId;
                    this.getServiceOpenid.filedId = this.coalDetailsData.filedId;
                }
            });
        },
@@ -130,12 +161,49 @@
        },
        // 呼叫客服
        callCustomerService() {
            wx.join1v1Chat({
                caller: { nickname: this.userName, openid: this.openid },
                listener: { nickname: '客服', openid: 'orutI5YT0yEvARVngdsTmBpisWmw' }, // 这里的openid是fyy的,充当固定的客服openid
                backgroundType: 2,
                roomType: 'voice'
            // if (!this.serviceInfoObj.openId) {
            // this.$u.toast('无客服信息');
            // }
            wx.getSetting({
                success(res) {
                    console.log('授权success', res);
                    if (!res.authSetting['scope.camera'] || !res.authSetting['scope.record']) {
                        if (!res.authSetting['scope.camera']) {
                            uni.showToast({
                                title: '无相机权限'
            });
                        } else if (!res.authSetting['scope.record']) {
                            uni.showToast({
                                title: '无麦克风权限'
                            });
                        }
                    } else {
                        wx.join1v1Chat({
                            caller: { nickname: uni.getStorageSync('name'), openid: uni.getStorageSync('openid') },
                            listener: { nickname: '付延余', openid: 'oZjXk5e7G9uIvOzaTO6nFV51ALwk' }, // 这里的openid是fyy的,充当固定的客服openid
                            backgroundType: 2,
                            roomType: 'voice',
                            success() {
                                console.log('一对一成功');
                            },
                            fail(err) {
                                console.log('一对一失败', err);
                            }
                        });
                    }
                },
                fail() {
                    console.log('获取失败');
                }
            });
        },
        calling() {
            // wx.join1v1Chat({
            //     caller: { nickname: this.name, openid: this.openid }, //oZjXk5RRmbroAfl1m5aZ6hRNvqh4
            //     listener: { nickname: this.serviceInfoObj.openName, openid: 'orutI5YT0yEvARVngdsTmBpisWmw' }, // 这里的openid是fyy的,充当固定的客服openid
            //     backgroundType: 2,
            //     roomType: 'voice'
            // });
        },
        // 称重
        cengZhongClick() {
@@ -170,8 +238,8 @@
        margin: vww(20);
        margin-bottom: vww(10);
        height: 40%;
        box-sizing: border-box;
        overflow-y: overlay; //行为与 auto 相同,但是滚动条绘制在内容之上,而不是占据空间。
        font-size:vww(16);
        font-weight: 500;
        .u-text {
            margin-bottom: vww(5) !important;
        }
@@ -180,12 +248,25 @@
        }
        view:nth-of-type(1) {
            display: flex;
            text{
                width:50%;
            }
        }
        view:nth-of-type(2) {
            display: flex;
            text{
                width:33%;
            }
        }
        view:nth-of-type(3) {
            display: flex;
            text{
                width:50%;
            }
        }
        view:nth-of-type(4){
            display:flex;
            flex-direction: column;
        }
    }
    .timeLine {
pages/driver-page/driver-index/bill-of-lading-details/weighingDevice/weighingDevice.vue
@@ -102,17 +102,17 @@
        realTimeWeigh(newV,oldV){
            if(this.weighList.orderTye == '外销'){
                if(this.weighList.skin == 0){
                    this.temporaryWeighObj.skin = this.realTimeWeigh
                    this.temporaryWeighObj.skin = this.realTimeWeigh;
                } else {
                    this.temporaryWeighObj.hair = this.realTimeWeigh
                    this.temporaryWeighObj.clean = this.temporaryWeighObj.hair - this.weighList.skin
                    this.temporaryWeighObj.hair = this.realTimeWeigh;
                    this.temporaryWeighObj.clean = this.temporaryWeighObj.hair - this.weighList.skin;
                }
            } else if(this.weighList.orderTye == '外购'){
                if(this.weighList.hair == 0){
                    this.temporaryWeighObj.hair = this.realTimeWeigh
                    this.temporaryWeighObj.hair = this.realTimeWeigh;
                } else {
                    this.temporaryWeighObj.skin = this.realTimeWeigh
                    this.temporaryWeighObj = this.weighList.hair - this.temporaryWeighObj.skin
                    this.temporaryWeighObj.skin = this.realTimeWeigh;
                    this.temporaryWeighObj = this.weighList.hair - this.temporaryWeighObj.skin;
                }
            }
        }
@@ -134,7 +134,7 @@
                    return false;
                }
            }
        },
        }
    },
    methods: {
        init() {
@@ -227,13 +227,13 @@
            // 获取服务器传来的数据,做相应处理
            socket.onMessage(res => {
                console.log('socketWeigh', res);
                let nowWeighObj = JSON.parse(res.data.slice(7))
                let nowWeighObj = JSON.parse(res.data.slice(7));
                if (nowWeighObj.eqCode == this.weighHouseCode) {
                    if(nowWeighObj.eqInfraredStatus){
                        this.infraredStatus = true
                        this.infraredStatus = true;
                        this.weighData.weigh = this.realTimeWeigh = nowWeighObj.weigh;
                    }else{
                        this.infraredStatus = false
                        this.infraredStatus = false;
                        this.weighData.weigh = this.realTimeWeigh = nowWeighObj.weigh;
                    }
                }
pages/login/login.vue
@@ -2,7 +2,7 @@
    <view class="login">
        <view class="logo">无人值守</view>
        <!--用户名密码登录-->
        <user-password :btnText='0'/>
        <user-password :btnText="0" />
        <!-- 微信openid登录 -->
        <view class="loginBtn">
            <u-button class="button" @click.stop="beforeLoginEvent" :disabled="btnLoading" :loading="btnLoading" type="primary" text="微信一键登录"></u-button>
@@ -39,7 +39,6 @@
export default {
    data() {
        return {
            wxcode: '', // 司机1
            btnLoading: false,
            loginPopupShow: false,
            // 绑定微信模态框
@@ -62,8 +61,7 @@
            uni.login({
                success: res => {
                    if (res.code) {
                        this.wxcode = res.code;
                        this.apiLogin();
                        this.apiLogin(res.code);
                    } else {
                        uni.showToast({
                            title: '微信登录失败!',
@@ -74,37 +72,18 @@
            });
        },
        // 登录接口
        apiLogin() {
            // apiLoginWx({ code: this.wxcode })
            //     .then(res => {
            //         console.log('请求登录', res);
            //         if (res.msg == '需绑定') {
            //             uni.navigateTo({
            //                 url: `/pages/register/register?code=${res.data}`
            //             });
            //         }
            //         if (res.msg == '登录成功') {
            //             uni.setStorageSync('userInfo', res.data);
            //             this.setUserTabbar(res.data.type);
            //             uni.switchTab({
            //                 url: '/pages/tabbar-page/index-tabbar/index-tabbar'
            //             });
            //         }
            //     })
            //     .catch(err => {
            //         console.log('错误', err);
            //     });
        apiLogin(code) {
            /**
             * @openid
             * 获取微信用户openid,微信一键登录暂无相关接口,用于测试呼叫客服功能
             */
            uni.showLoading({
                title: '加载中...'
            });
            wx.request({
                url: `https://api.weixin.qq.com/sns/jscode2session?appid=wx4a62fc1684c429a9&secret=ee90afe376cdcec2fdd947c0a4db961a&js_code=${this.wxcode}&grant_type=authorization_code`,
                url: `https://api.weixin.qq.com/sns/jscode2session?appid=wx4a62fc1684c429a9&secret=ee90afe376cdcec2fdd947c0a4db961a&js_code=${code}&grant_type=authorization_code`,
                success(res) {
                    let id = res.data.openid;
                    uni.setStorageSync('openid', id);
                    uni.setStorageSync('openid', res.data.openid);
                    uni.showToast({
                        title: '成功获取测试openid',
                        icon: 'none'
@@ -113,6 +92,7 @@
            });
            this.$nextTick(() => {
                apiLoginWx({ code: uni.getStorageSync('openid') }).then(res => {
                    uni.hideLoading();
                    if (res.code != 1) {
                        this.$u.toast('恭喜您,登录成功!');
                        // 登陆成功,存储相关信息
@@ -135,7 +115,6 @@
                    }
                });
            });
            this.loginPopupShow = false;
        },
        bindWxConfirm() {
pages/login/userPassword.vue
@@ -31,7 +31,7 @@
<script>
import { apiLoginPassword } from '@/api/publicInterface.js';
import { mapMutations } from 'vuex';
import { setToken, setRefreshToken, setUsernameKey, setCustomerId, redirectHome } from '@/utils/status.js';
import { setName, setToken, setRefreshToken, setUsernameKey, setCustomerId, redirectHome } from '@/utils/status.js';
export default {
    name: 'userPassword',
    props: {
@@ -90,6 +90,7 @@
                                    this.setUserTabbar(res.data.type);
                                    uni.setStorageSync('roleType', res.data.type);
                                    setCustomerId(res.data.customerid);
                                    setName(res.name);
                                    uni.hideLoading();
                                    //跳转页面
                                    this.$nextTick(() => {
@@ -105,8 +106,7 @@
                            this.$u.toast(res.msg);
                        }
                    } else {
                        this.$nextTick(() => {
                            this.$reqPost('wxBind', { state: 'MINI', code: uni.getStorageSync('code') }, 'params').then(res => {
                        this.$reqPost('wxBind', { state: 'MINI', code: uni.getStorageSync('openid') }, 'params').then(res => {
                                uni.hideLoading();
                                if (res.code == 0) {
                                    this.$u.toast('绑定成功!即将回到登录页!');
@@ -116,7 +116,6 @@
                                } else {
                                    this.$u.toast(res.msg ? res.msg : '绑定失败');
                                }
                            });
                        });
                    }
                })
pages/tabbar-page/index-tabbar/index-tabbar.vue
@@ -18,6 +18,23 @@
        driverIndex,
        freightForwarderIndex
    },
    onLoad(){
        // 开启双人通话
        wx.setEnable1v1Chat({
            enable: true,
            backgroundType: 1,
            minWindowType:2,
            success() {
                console.log('开启双人通话成功');
            },
            fail() {
                console.log('开启双人通话失败');
            },
            complete() {
                console.log('开启双人通话成功Complete');
            }
        });
    },
    data() {
        return {
            roleType: null
@@ -57,7 +74,7 @@
        userAuthorization() {
            wx.getSetting({
                success(res) {
                    wx.startRecord();
                    // wx.startRecord();
                    console.log('success');
                    if (!res.authSetting['scope.record'] || !res.authSetting['scope.camera']) {
                        if (!res.authSetting['scope.camera']) {
utils/status.config.js
@@ -6,3 +6,4 @@
export const FailRedirect = '/pages/login/login';
export const SuccessRedirect = '/pages/tabbar-page/index-tabbar/index-tabbar';
export const customerIdKey = 'customerId';
export const nameKey = 'name';
utils/status.js
@@ -4,7 +4,8 @@
    UsernameKey,
    SuccessRedirect,
    FailRedirect,
    customerIdKey
    customerIdKey,
    nameKey
} from './status.config.js';
const SetStorage = (key) => (value) => uni.setStorageSync(key, value);
@@ -12,7 +13,8 @@
export const setToken = SetStorage(TokenKey);
export const setRefreshToken = SetStorage(RefreshToken);
export const setUsernameKey = SetStorage(UsernameKey);
export const setCustomerId = SetStorage(customerIdKey)
export const setCustomerId = SetStorage(customerIdKey);
export const setName = SetStorage(nameKey)
export const redirectHome = (path) => {
    uni.switchTab({
        url: path || SuccessRedirect