123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553 |
- <template>
- <view class="code">
- <view class="info_box">
- <view class="user flexS" v-if="userInfo">
- <text>客户:</text>
- <view>{{userInfo.nickname|getName(15)||''}}</view>
- <view v-if="userInfo.phone!=userInfo.nickname">{{userInfo.phone||''}}</view>
- </view>
- <view class="info flexS" style="border-top:2rpx solid #eee;">
- <view class="top_left">
- <text>款式</text>
- <text>状态</text>
- </view>
- <view>纯棉版</view>
- <view>精装版</view>
- <view>老人版</view>
- <view>简约版</view>
- <view>总计</view>
- </view>
- <view class="info order_num flexS">
- <view style="line-height: 7vh;">应发货</view>
- <view>{{cottonNum}}</view>
- <view>{{hardNum}}</view>
- <view>{{oldNum}}</view>
- <view>{{simpleNum}}</view>
- <view>{{orderTotal}}</view>
- </view>
- <view class="info num flexS">
- <view style="line-height: 7vh;">已扫码</view>
- <view>{{cotton}}</view>
- <view>{{hard}}</view>
- <view>{{old}}</view>
- <view>{{simple}}</view>
- <view>{{total}}</view>
- </view>
- </view>
- <view class="scroll">
- <scroll-view scroll-y="true">
- <view class="code_box">
- <view class="code_info flexB" v-for="(item,idx) in codeList" :key="idx">
- <text>{{item.security_code}}</text>
- <text>{{item.good_select_id|getGoods}}</text>
- <view class="search_btn" @click="delCode(item.id,idx)">删除</view>
- </view>
- </view>
- </scroll-view>
- </view>
- <view class="fixed_box flexB">
- <view @click="cancel">重新扫描</view>
- <view class="scan_code flexC" @click="scanCode()">扫描</view>
- <view @click="submit">确认发货</view>
- </view>
- </view>
- </template>
- <script>
- import {
- getUser,
- scanCodeInfo,
- submitCodeInfo,
- orderQuery,
- delScancode
- } from '../../../apis/shop.js'
- export default {
- data() {
- return {
- codeList: [], //防伪码
- userInfo: '', // 用户信息
- cotton: 0, //纯棉老人版
- hard: 0, //精装
- old: 0, //老人
- simple: 0, //简约
- // total: 0, //防伪码数量
- order_no: '', //订单编号
- user_id: '', //用户id
- orderTotal: 0, //订单里的商品数量
- isPoint: true, //是否可以点击
- goods: '', //订商品详情
- cottonNum: 0,
- hardNum: 0,
- oldNum: 0,
- simpleNum: 0,
- goods_id: [],
- ids: [] //重新扫描时需要删除的id合集
- }
- },
- onLoad(ops) {
- this.getOrder(ops.order_no);
- this.order_no = ops.order_no;
- },
- computed: {
- total() {
- return this.cotton + this.hard + this.old + this.simple || 0
- }
- },
- filters: {
- getGoods(id) {
- switch (id) {
- case 1:
- return '精装版'
- break;
- case 2:
- return '简约版'
- break;
- case 3:
- return '老人版'
- break;
- case 4:
- return '纯棉老人版'
- break;
- default:
- break;
- }
- },
- },
- methods: {
- //总件数
- totalNum(data) {
- let total = 0
- for (let k in data) {
- total += data[k].sku.reduce((t, e) => t + Number(e.num), 0)
- }
- return total;
- },
- /*获取订单详情*/
- getOrder(order_no) {
- orderQuery({
- order_no
- })
- .then(res => {
- if (res.code == 200) {
- let list = res.data;
- const {
- code,
- goods
- } = res.data;
- code.map(j => {
- this.codeList.push({
- good_select_id: j.good_select_id,
- code: j.code,
- security_code: j.security_code,
- id: j.id,
- })
- this.ids.push(j.id)
- this.changeNum(j.good_select_id, true)
- })
- goods.map(i => {
- let num = i.sku.reduce((t, e) => t + Number(e.num), 0);
- if (i.id == 1) {
- this.hardNum = num
- }
- if (i.id == 2) {
- this.simpleNum = num
- }
- if (i.id == 3) {
- this.oldNum = num
- }
- if (i.id == 4) {
- this.cottonNum = num
- }
- this.goods_id.push(i.id);
- })
- this.userInfo = res.data.user;
- this.orderTotal = this.totalNum(goods)
- } else {
- uni.showModal({
- content: res.data || '获取订单详情失败',
- showCancel: false
- });
- }
- })
- .catch(err => {});
- },
- //扫码发货
- submit() {
- let code = [];
- this.codeList.map(i => {
- if (!i.id) {
- code.push(i.code)
- }
- })
- if (this.codeList.length != this.orderTotal) {
- uni.showModal({
- content: '发货防伪码数量与订单套数不一致',
- showCancel: false
- })
- return false;
- };
- if (code.length == 0) {
- uni.redirectTo({
- url: '../delivery-method/delivery-method?user_id=' +
- this.userInfo.id + '&order_no=' + this
- .order_no
- })
- return false
- }
- uni.showLoading({
- title: '提交中...',
- mask: true
- })
- submitCodeInfo({
- code,
- order_no: this.order_no
- }).then(res => {
- if (res.code == 200) {
- uni.showModal({
- content: '发货防伪码提交成功',
- showCancel: false,
- success: res => {
- if (res.confirm) {
- uni.redirectTo({
- url: '../delivery-method/delivery-method?user_id=' +
- this.userInfo.id + '&order_no=' + this
- .order_no
- })
- }
- }
- })
- } else {
- uni.showModal({
- content: res.data || '提交失败',
- showCancel: false
- })
- }
- uni.hideLoading()
- }).catch(err => {
- uni.hideLoading()
- })
- },
- changeNum(id, type) {
- switch (id) {
- case 1:
- type ? this.hard++ : this.hard--
- return '精装版'
- break;
- case 2:
- type ? this.simple++ : this.simple--
- return '简约版'
- break;
- case 3:
- type ? this.old++ : this.old--
- return '老人版'
- break;
- case 4:
- type ? this.cotton++ : this.cotton--
- return '纯棉老人版'
- break;
- default:
- break;
- }
- },
- //重新扫描
- cancel() {
- uni.showModal({
- content: '确定要重新扫描吗,重新扫描将清除所有数据',
- success: res => {
- if (res.confirm) {
- if (this.ids.length == 0) {
- this.codeList = [];
- this.cotton = this.hard = this.old = this.simple = 0;
- return false
- }
- delScancode({
- ids: this.ids
- }).then(res => {
- if (res.code == 200) {
- uni.showToast({
- title: '删除成功'
- })
- this.ids = [];
- this.codeList = [];
- this.cotton = this.hard = this.old = this.simple = 0;
- } else {
- uni.showModal({
- content: res.data || '删除失败',
- showCancel: false
- })
- }
- })
- }
- }
- })
- },
- //删除
- delCode(id, idx) {
- uni.showModal({
- content: '确定要删除当前数据吗?',
- success: res => {
- if (res.confirm) {
- if (id) { //删除已提交的code码
- this.delOrderCode(id, idx);
- return false;
- }
- this.changeNum(this.codeList[idx].good_select_id, false)
- this.codeList.splice(idx, 1)
- uni.showToast({
- title: '删除成功'
- })
- }
- }
- })
- },
- //删除订单列表中的code
- delOrderCode(id, idx) {
- let ids = [id]
- delScancode({
- ids
- }).then(res => {
- if (res.code == 200) {
- uni.showToast({
- title: '删除成功'
- })
- //删除数组中的id
- let index = this.ids.indexOf(id)
- if (index > -1) {
- this.ids.splice(index, 1);
- }
- this.changeNum(this.codeList[idx].good_select_id, false)
- this.codeList.splice(idx, 1)
- } else {
- uni.showModal({
- content: res.data || '删除失败',
- showCancel: false
- })
- }
- })
- },
- //直接扫码发货
- scanCode() {
- let list = [];
- this.codeList.map(i => {
- list.push(i.code)
- })
- uni.scanCode({
- success: res => {
- var idx = res.result.lastIndexOf("\?"); //idx等于-1代表扫的是新码
- var index = idx === -1 ? res.result.lastIndexOf("\/") : res.result;
- let codeNum = res.result.substring(index + 1, res.result.length);
- if (list.indexOf(codeNum) === -1) {
- uni.showLoading({
- title: '识别中...'
- })
- scanCodeInfo({
- code: codeNum
- }).then(res => {
- if (res.code == 200) {
- if (this.goods_id.indexOf(res.data.good_select_id) === -1) {
- uni.showModal({
- content: '订单不存在此规格',
- showCancel: false
- })
- return false;
- }
- this.changeNum(res.data.good_select_id, true)
- if (this.hard > this.hardNum || this.cotton > this.cottonNum ||
- this.simple > this.simpleNum || this
- .old > this.oldNum) {
- uni.showModal({
- content: '超出此规格数量',
- showCancel: false,
- })
- this.changeNum(res.data.good_select_id, false)
- return false;
- }
- this.codeList.push({
- good_select_id: res.data.good_select_id,
- code: res.data.code,
- security_code: res.data.security_code,
- id: '',
- })
- } else {
- uni.showModal({
- content: res.data || '扫码失败,请重试',
- showCancel: false
- })
- }
- uni.hideLoading()
- }).catch(err => {
- uni.hideLoading()
- })
- } else {
- uni.showModal({
- content: '防伪码已存在',
- showCancel: false
- })
- }
- },
- fail: err => {
- uni.showModal({
- content: '扫码失败',
- showCancel: false
- })
- }
- });
- },
- }
- }
- </script>
- <style lang="scss" scoped>
- .code {
- width: 100%;
- height: 100vh;
- position: relative;
- .info_box {
- width: 100%;
- height: 28vh;
- .top_left {
- position: relative;
- text {
- position: absolute;
- }
- text:first-child {
- top: 2rpx;
- right: 7rpx;
- }
- text:last-child {
- bottom: 2rpx;
- left: 7rpx;
- }
- &::after {
- display: block;
- content: '';
- width: 147rpx;
- height: 2rpx;
- background: #eee;
- transform: rotate(34deg);
- position: absolute;
- top: 43rpx;
- left: -12rpx;
- }
- }
- .info,
- .user {
- width: 100%;
- height: 7vh;
- view,
- text {
- font-size: 28rpx;
- font-weight: bold;
- }
- }
- .info {
- >view {
- width: 20%;
- text-align: center;
- height: 7vh;
- border-right: 2rpx solid #EEEEEE;
- }
- >view:not(:first-child) {
- line-height: 7vh;
- }
- }
- .user {
- padding-left: 30rpx;
- box-sizing: border-box;
- }
- .num {
- background: #FFF4F3;
- view {
- color: $base-color;
- }
- }
- .order_num {
- background: #f8f8f8;
- view {
- color: #333;
- }
- }
- }
- .scroll {
- width: 100%;
- height: 68vh;
- scroll-view {
- width: 100%;
- height: 100%;
- }
- .code_box {
- padding-bottom: 140rpx;
- width: 100%;
- .code_info {
- width: 100%;
- padding: 0 24rpx;
- box-sizing: border-box;
- height: 104rpx;
- text {
- width: 33.33%;
- text-align: left;
- font-size: 32rpx;
- }
- }
- .code_info:nth-child(2n) {
- background: #F8F8F8;
- }
- }
- }
- }
- .fixed_box {
- width: 100%;
- height: 100rpx;
- background: #fff;
- position: fixed;
- box-shadow: 0px -4rpx 24rpx rgba(0, 0, 0, 0.1);
- bottom: 0;
- left: 0;
- padding: 0 50rpx;
- box-sizing: border-box;
- view {
- font-size: 32rpx;
- color: $base-color;
- font-weight: bold;
- }
- .scan_code {
- width: 172rpx;
- height: 172rpx;
- background: $base-line-bg;
- box-shadow: 0px 6rpx 20rpx rgba(254, 34, 0, 0.43);
- font-size: 40rpx;
- border-radius: 50%;
- color: #fff;
- margin-top: -108rpx;
- letter-spacing: 5rpx;
- }
- }
- </style>
|