123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454 |
- <template>
- <view class="send_box">
- <view class="guide_box" v-if="showGuide" @click="showGuide = false">
- <image src="../../static/imgs/shop/express.png" mode="" class="express_img"></image>
- </view>
- <view class="send_goods">
- <view>
- <view class="label">
- <text>快递单号</text>
- <text>*</text>
- </view>
- <view class="flexB scan_box">
- <input type="text" placeholder="在此输入快递单号" placeholder-class="place" v-model="num" />
- <view class="scan_btn flexCC" @click="scanCode()">快速录入单号</view>
- </view>
- </view>
- <view>
- <view class="label">
- <text>快递公司</text>
- <text>*</text>
- </view>
- <picker @change="bindPickerChange" :value="index" :range="logs" :range-key="'name'">
- <view class="picker flexB">
- <view class="inp_box" :style="{ color: logsName ? '#333' : '#999' }">
- {{ logsName ? logsName : '请选择快递公司' }}
- </view>
- <text class="iconfont iconzhcc_xiangxiajiantou"></text>
- </view>
- </picker>
- </view>
- <view v-if="logsName == '顺丰速运' || logsName == '顺丰快递'">
- <view class="label">
- <text>收货人手机号</text>
- <text>*</text>
- </view>
- <input type="text" placeholder="在此输入收货人手机号" placeholder-class="place" v-model="express_phone" />
- </view>
- <view>
- <view class="label">
- <text>发货日期</text>
- <text>*</text>
- </view>
- <picker @change="bindDateChange" mode="date" :value="date" :start="startDay">
- <view class="picker flexB">
- <view class="inp_box">{{ date }}</view>
- <text class="iconfont iconzhcc_xiangxiajiantou"></text>
- </view>
- </picker>
- </view>
- <view class="sub_btn" @click="submit">提交</view>
- </view>
- </view>
- </template>
- <script>
- import {
- getLogsCode,
- addLogs,
- getAds,
- location,
- getExpress
- } from '../../apis/shop.js';
- // var jweixin = require('jweixin-module');
- export default {
- data() {
- const currentDate = this.getDate({
- format: true
- });
- return {
- num: '', //物流单号
- logs: [], //物流名称选项
- logsName: '', //物流公司名称
- logsCode: '', //物流公司编码
- order_no: '', //订单编号
- index: 0, //选择物流名称
- date: currentDate, //发货日期
- startDay: '2020-01-01',
- user_id: '',
- address: '', //从下个页面选择的地址
- defaultAds: '', //获取的默认地址
- ads: {
- province: '',
- city: '',
- area: '',
- location: ''
- },
- userName: '',
- userPhone: '',
- userAds: '',
- express_phone: '', //发货时候如果是顺丰速运填写用户手机号
- showGuide: true
- };
- },
- onLoad(ops) {
- this.order_no = ops.order_no;
- this.user_id = ops.user_id;
- this.getCode();
- },
- methods: {
- //扫码获取单号
- scanCode() {
- this.showGuide = false;
- uni.scanCode({
- success: res => {
- let code = res.result;
- console.log(res, 2222)
- this.getExpress(code);
- },
- fail: err => {
- console.log(err, 1111)
- uni.showModal({
- content: '扫码失败',
- showCancel: false
- })
- }
- });
- },
- //根据单号获取物流公司
- getExpress(expressCode) {
- uni.showLoading({
- title: '识别中...',
- mask: true
- })
- getExpress({
- expressCode
- }).then(res => {
- if (res.code == 200) {
- if (!res.data.Success) {
- uni.showModal({
- content: '请重新扫码或手动选择输入',
- showCancel: false
- });
- return false;
- }
- this.num = res.data.LogisticCode;
- if (res.data.Shippers) {
- const {
- ShipperName,
- ShipperCode
- } = res.data.Shippers[0];
- this.logsName = ShipperName;
- this.logsCode = ShipperCode;
- } else {
- uni.showModal({
- content: '请重新扫码或手动选择输入',
- showCancel: false
- });
- this.logsName = this.logsCode = '';
- }
- } else {
- uni.showModal({
- content: res.data || '获取数据失败',
- showCancel: false
- });
- }
- uni.hideLoading();
- }).catch(err => {
- uni.hideLoading();
- })
- },
- /*添加地址*/
- addressList() {
- uni.navigateTo({
- url: '../ads-list/ads-list?user_id=' + this.user_id
- });
- },
- /*获取物流的*/
- getCode() {
- getLogsCode().then(res => {
- if (res.code == 200) {
- let list = res.data;
- for (let key in list) {
- this.logs.push({
- code: key,
- name: list[key]
- });
- }
- } else {
- uni.showModal({
- content: res.data || '获取物流公司失败',
- showCancel: false
- });
- }
- });
- },
- /*选择物流公司*/
- bindPickerChange(e) {
- let idx = e.detail.value;
- this.index = idx;
- this.logsName = this.logs[idx].name;
- this.logsCode = this.logs[idx].code;
- },
- /*选择日期*/
- bindDateChange(e) {
- this.date = e.target.value;
- console.log(this.date);
- },
- getDate(type) {
- const date = new Date();
- let year = date.getFullYear();
- let month = date.getMonth() + 1;
- let day = date.getDate();
- if (type === 'start') {
- year = year - 60;
- } else if (type === 'end') {
- year = year + 2;
- }
- month = month > 9 ? month : '0' + month;
- day = day > 9 ? day : '0' + day;
- return `${year}-${month}-${day}`;
- },
- submit() {
- // if (!this.address.id && !this.defaultAds.id) {
- // uni.showModal({
- // content: '发货地址不能为空',
- // showCancel: false
- // });
- // return false;
- // }
- if (!this.num) {
- uni.showModal({
- content: '物流单号不能为空',
- showCancel: false
- });
- return false;
- }
- if (this.logsName == '请选择物流公司') {
- uni.showModal({
- content: '物流名称不能为空',
- showCancel: false
- });
- return false;
- }
- if (this.logsName == '顺丰速运' && !this.express_phone) {
- uni.showModal({
- content: '请输入收货人手机号',
- showCancel: false
- });
- return false;
- }
- if (!this.date) {
- uni.showModal({
- content: '发货日期不能为空',
- showCancel: false
- });
- return false;
- }
- uni.showLoading({
- title: '提交中....'
- });
- addLogs({
- order_no: this.order_no,
- express_no: this.num,
- express_code: this.logsCode,
- express_company: this.logsName,
- express_time: this.date,
- address_id: this.address.id || this.defaultAds.id || '',
- express_phone: this.express_phone
- })
- .then(res => {
- if (res.code == 200) {
- uni.showModal({
- content: '发货成功',
- showCancel: false,
- success: res => {
- if (res.confirm) {
- uni.reLaunch({
- url: '../order-manage/order-manage?status=' + 3
- });
- }
- }
- });
- } else {
- uni.showModal({
- content: res.data || '发货失败',
- showCancel: false
- });
- }
- uni.hideLoading();
- })
- .catch(err => {
- uni.hideLoading();
- });
- }
- }
- };
- </script>
- <style lang="scss" scoped>
- .guide_box {
- width: 100vw;
- height: 100vh;
- position: fixed;
- top: 0;
- left: 0;
- background: rgba(0, 0, 0, 0.5);
- display: flex;
- flex-direction: column;
- align-items: center;
- z-index: 999;
- .express_img {
- width: 608rpx;
- height: 731rpx;
- margin-top: 20vh;
- }
- }
- .scan_box {
- width: 690rpx;
- background: #f9f9fb;
- border-radius: 8rpx;
- .scan_btn {
- width: 196rpx;
- height: 60rpx;
- background: #fff4f3;
- border: 2rpx solid #fb231f;
- border-radius: 34rpx;
- color: $base-color;
- margin-right: 10rpx;
- z-index: 999999;
- }
- input {
- width: 70%;
- }
- }
- .send_box {
- width: 100%;
- min-height: 100%;
- background: #fff;
- .send_goods {
- width: 690rpx;
- padding-top: 30rpx;
- margin: 0 auto;
- background-color: #fff;
- .label {
- margin: 30rpx 0;
- text:first-child {
- font-size: 32rpx;
- font-weight: bold;
- }
- text:last-child {
- font-size: 32rpx;
- color: $base-color;
- font-weight: bold;
- }
- }
- .picker {
- background: #f9f9fb;
- height: 88rpx;
- line-height: 88rpx;
- border-radius: 8rpx;
- padding: 0 30rpx;
- .iconfont {
- color: #999;
- }
- .inp_box {
- font-size: 30rpx;
- }
- }
- input {
- height: 88rpx;
- background: #f9f9fb;
- border-radius: 8rpx;
- padding-left: 30rpx;
- box-sizing: border-box;
- font-size: 30rpx;
- }
- .place {
- font-size: 30rpx;
- color: #999;
- }
- .sub_btn {
- margin: 60rpx auto 50rpx;
- }
- .address_box {
- padding: 30rpx;
- width: 100%;
- box-sizing: border-box;
- background-color: #f9f9fb;
- border-radius: 24rpx;
- .icondizhi1 {
- color: $base-color;
- font-size: 50rpx;
- vertical-align: middle;
- }
- .add_box {
- margin-left: 20rpx;
- font-size: 30rpx;
- color: #999;
- }
- .iconiconfontjiantou2 {
- color: #999;
- }
- .ads_info {
- margin: 0 15rpx;
- .shop_info {
- font-size: 32rpx;
- font-weight: bold;
- text:last-child {
- font-size: 28rpx;
- color: #999;
- }
- }
- .ads_del {
- margin-top: 15rpx;
- }
- }
- }
- .scan_box {
- width: 690rpx;
- background: #f9f9fb;
- border-radius: 8rpx;
- .scan_btn {
- width: 196rpx;
- height: 60rpx;
- background: #fff4f3;
- border: 2rpx solid #fb231f;
- border-radius: 34rpx;
- color: $base-color;
- margin-right: 10rpx;
- }
- input {
- width: 70%;
- }
- }
- }
- }
- </style>
|