123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689 |
- <template>
- <view>
- <view class="demo" style="height: 180rpx;">
- <view class="detailMiddle">
- <text>精</text>
- <text>简</text>
- <text>高</text>
- <text>纯棉</text>
- <text>赠</text>
- <text>青春</text>
- <text>总计</text>
- </view>
- <view class="detailMiddleRed">
- <text v-for="(item,index) in numList" :key="index">{{ item }}</text>
- <text>{{ allNum }}</text>
- </view>
- </view>
- <!-- <view @click="getScan">
- 点击添加
- </view>
- <view @click="setC">
- 点击校验
- </view> -->
- <scroll-view :style="{height: scroll_height}" class="listBox" scroll-y="true">
- <view class="listBox_item" :class="(index + 1)%2 == 0 ? 'back' : ''" v-for="(item,index) in list"
- :key="index">
- <view style="display: flex;align-items: center;width:50%">
- <view class="left">
- {{ item.style }}
- </view>
- <view class="gray">
- {{ item.code_level==1?item.code_num:1 }}套{{item.code_level==1?`(1件)`:''}}
- </view>
- </view>
- <view class="right" @click="del(item.style,index)">
- 删除
- </view>
- </view>
- </scroll-view>
- <view class="fiexedEnd">
- <view class="fiexedEnd_title" @click="allDel">
- 全部清除
- </view>
- <view class="fiexedEnd_red" @click="getCode">
- 扫描
- </view>
- <view class="fiexedEnd_title" @click="sendSure">
- 确认发货
- </view>
- </view>
- <!-- <u-mask :show="fillOut">
- <view class="showTip">
- <image src="../../static/fangwei/show.png"></image>
- <view class="title">
- 温馨提示
- </view>
- <view class="remark">
- 是否确保这一件里的所有货没有调换过
- </view>
- <view class="btn">
- <view class="btn_left" @click="fillOut = false">
- 不确保
- </view>
- <view class="btn_right" @click="getCode">
- 确保
- </view>
- </view>
- </view>
- </u-mask> -->
- <u-mask :show="ifShow">
- <view class="showTip">
- <image src="../../static/fangwei/show.png"></image>
- <view class="title">
- 提示
- </view>
- <view class="remark">
- 添加成功!
- </view>
- <view class="btn">
- <view class="btn_left" @click="ifShow = false,clearTime()">
- 取消
- </view>
- <view class="btn_right" @click="getCode">
- 扫下一个({{ count }}s)
- </view>
- </view>
- </view>
- </u-mask>
- <u-modal v-model="show" :show-cancel-button="true" :content="content" @confirm="confirm"></u-modal>
- <u-toast ref="uToast" />
- </view>
- </template>
- <script>
- import {
- scanCode,
- UserSend,
- AllSendGood
- } from '../../apis/fangwei.js'
- import {
- location,
- } from '../../apis/user.js';
- var jweixin = require('jweixin-module');
- export default {
- data() {
- return {
- show: false,
- fillOut: false,
- delShow: false,
- ifShow: false,
- content: '',
- count: 3,
- list: [],
- id: '',
- scroll_height: 0,
- numList: [0, 0, 0, 0, 0, 0],
- info: {},
- code: '',
- allNum: 0,
- param: {},
- model: '', //手机型号
- }
- },
- // 获取可滑动区域的高度
- onReady: function(res) {
- var _this = this;
- uni.getSystemInfo({
- success: (resu) => {
- const query = uni.createSelectorQuery()
- query.select('.listBox').boundingClientRect()
- query.exec(function(res) {
- _this.scroll_height = resu.windowHeight - res[0].top + 'px';
- })
- },
- fail: (res) => {}
- })
- },
- onLoad: function(option) {
- this.id = option.id
- // 用于扫码发货
- uni.getSystemInfo({
- success: res => {
- this.model = res.model;
- }
- });
- if (this.model == 'iPhone') {
- uni.setStorageSync('url', window.location.href.split('#')[0])
- }
- // this.getInfo('21tJfNcVaKd04b1872275KDNN76Q0109') //一件
- // this.getInfo('21eDalw4pdbobc8725ea4C4QNKR_0109') //一套
- // this.getInfo('21As3wSFW4pV75d9e6bcF0A_N4N30109') //一套精装赠
- },
- methods: {
- setC() {
- this.count = 3
- this.ifShow = true
- this.setTime()
- let index = this.list.findIndex(item => item.code == '44444')
- if (index != -1) {
- console.log('存在')
- } else {
- console.log('不存在')
- }
- },
- // 测试扫描
- getScan() {
- var good = 4
- var style = this.getStyle(good)
- const data = {
- style: this.getStyle(good),
- styleId: 4,
- code: 44444
- }
- this.URLencode(data)
- console.log(data)
- this.list.unshift(data)
- console.log(this.list)
- this.addStyle(good)
- },
- setTime() {
- //设置定时器
- this.clearTimeSet = setInterval(() => {
- this.count--;
- if (this.count == 0) {
- this.ifShow = false
- this.clearTime()
- this.getCode()
- }
- }, 1000);
- },
- clearTime() {
- console.log('清除')
- //清除定时器
- clearInterval(this.clearTimeSet);
- },
- // 确认发货
- sendGood() {
- const data = {
- 1: [],
- 2: [],
- 3: [],
- 4: [],
- 5: [],
- 6: []
- }
- this.list.forEach((item, index, arr) => {
- data[item.styleId].push(item.code)
- })
- AllSendGood({
- id: this.id,
- code: data
- }).then(res => {
- if (res.code == 200) {
- uni.showToast({
- title: '发货成功',
- icon: 'none'
- })
- this.list = []
- this.numList = [0, 0, 0, 0]
- this.allNum = 0
- } else {
- uni.showModal({
- title: '错误提示',
- content: res.message || '发货失败',
- showCancel: false
- })
- }
- })
- },
- // 删除单个 弹窗
- del(item, i) {
- this.item = item
- this.i = i
- this.type = 1
- this.content = '确定要删除吗?'
- this.show = true
- },
- // 删除所有 弹窗
- allDel() {
- if (this.list.length == 0) {
- uni.showToast({
- title: '暂无货物',
- icon: 'none'
- })
- return false
- }
- this.content = '确定要全部清除吗?'
- this.type = 2
- this.show = true
- },
- // 发货调起确认框
- sendSure() {
- if (this.list.length == 0) {
- uni.showToast({
- title: '暂无货物',
- icon: 'none'
- })
- return false
- }
- this.type = 3
- this.show = true
- this.content = '确定要发货吗?'
- },
- confirm() {
- // 删除单个
- if (this.type == 1) {
- this.list.splice(this.i, 1)
- this.reduceStyle(this.item)
- uni.showToast({
- title: '删除成功',
- icon: 'none'
- })
- // 删除所有
- } else if (this.type == 2) {
- this.list = []
- this.numList = [0, 0, 0, 0, 0, 0]
- this.allNum = 0
- } else if (this.type == 3) {
- this.sendGood()
- }
- },
- // 款式
- getStyle(v) {
- if (v == 1) {
- return '精装版'
- } else if (v === 2) {
- return '简约版'
- } else if (v === 3) {
- return '高腰版'
- } else if (v === 4) {
- return '纯棉版'
- } else if (v === 5) {
- return '精装赠'
- } else if (v === 6) {
- return '青春版'
- }
- },
- // 增加款式数量
- addStyle(v) {
- if (v == 1) {
- this.numList[0] += 1
- } else if (v === 2) {
- this.numList[1] += 1
- } else if (v === 3) {
- this.numList[2] += 1
- } else if (v === 4) {
- this.numList[3] += 1
- } else if (v === 5) {
- this.numList[4] += 1
- } else if (v === 6) {
- this.numList[5] += 1
- }
- this.allNum += 1
- },
- // 减少款式数量
- reduceStyle(v) {
- if (v === '精装版') {
- this.numList[0] -= 1
- } else if (v === '简约版') {
- this.numList[1] -= 1
- } else if (v === '高腰版') {
- this.numList[2] -= 1
- } else if (v === '纯棉版') {
- this.numList[3] -= 1
- } else if (v === '精装赠') {
- this.numList[4] -= 1
- } else if (v === '青春版') {
- this.numList[5] -= 1
- }
- this.allNum -= 1
- },
- //获取信息
- getInfo(params) {
- UserSend({
- id: this.id,
- code: params
- }).then(res => {
- if (res.code == 200) {
- const data = {
- style: this.getStyle(res.data.good),
- styleId: res.data.good,
- code: params,
- code_level: res.data.code_level,
- code_num: res.data.code_num
- }
- this.list.unshift(data)
- this.addStyle(res.data.good)
- this.count = 3
- this.ifShow = true
- this.setTime()
- } else {
- uni.showModal({
- title: '错误提示',
- content: res.message || '获取信息失败',
- showCancel: false
- })
- }
- })
- },
- getCode() {
- this.ifShow = false
- this.clearTime()
- let link = window.location.href;
- let url = this.model == 'iPhone' ? uni.getStorageSync('url') : link
- location({
- url
- }).then(res => {
- if (res.code == 200) {
- let data = JSON.parse(res.data);
- // 判断是否支持扫码
- jweixin.config({
- debug: false, //开启debug模式.正式环境设置为false,测试环境设置为true
- appId: data.appId,
- timestamp: data.timestamp,
- nonceStr: data.nonceStr,
- signature: data.signature,
- jsApiList: ['scanQRCode'] //根据需要看需要哪些SDK的功能
- });
- // sdk加载完成后执行
- jweixin.ready(() => {
- jweixin.checkJsApi({
- jsApiList: ['scanQRCode'],
- success: res => {
- if (res.checkResult.scanQRCode == false) {
- alert('你的微信版本太低,不支持微信JS接口,请升级到最新的微信版本!');
- return;
- }
- }
- });
- jweixin.error(res => {
- console.log(res.errMsg, '错误消息');
- });
- //扫码
- jweixin.scanQRCode({
- needResult: 1, // 默认为0,扫描结果由微信处理,1则直接返回扫描结果,
- scanType: ['qrCode', 'barCode'], // 可以指定扫二维码还是一维码,默认二者都有
- success: res => {
- var result = res.resultStr; // 当needResult 为 1 时,扫码返回的结果
- var site = result.lastIndexOf('\/')
- var params = result.substring(site + 1, result.length)
- this.code = window.encodeURIComponent(params)
- let index = this.list.findIndex(item => item.code == this
- .code)
- if (index != -1) {
- uni.showModal({
- title: '错误提示',
- content: '此码已添加,请勿重复扫描',
- showCancel: false
- })
- } else {
- this.getInfo(this.code)
- }
- },
- fail: () => {
- location.href = location.protocol + '//' + location.host +
- "/pages/scanQR/detail";
- },
- });
- });
- } else {
- uni.showModal({
- title: '错误提示',
- content: res.message || '获取信息失败',
- showCancel: false
- })
- }
- });
- }
- // getCode() {
- // this.ifShow = false
- // this.clearTime()
- // // this.fillOut = false
- // const script = document.createElement('script');
- // script.type = 'text/javascript';
- // script.src = 'http://res.wx.qq.com/open/js/jweixin-1.4.0.js';
- // document.getElementsByTagName('head')[0].appendChild(script);
- // script.onload = () => {
- // scanCode().then(res => {
- // if (res.code == 200) {
- // wx.config({
- // debug: false, // 开启调试模式
- // appId: res.data.appId, // 必填,公众号的唯一标识
- // timestamp: res.data.timestamp, // 必填,生成签名的时间戳
- // nonceStr: res.data.nonceStr, // 必填,生成签名的随机串
- // signature: res.data.signature, // 必填,签名,见附录1
- // jsApiList: res.data.jsApiList // 必填,需要使用的JS接口列表,所有JS接口列表见附录2
- // })
- // wx.ready(() => {
- // wx.scanQRCode({
- // needResult: 1, // 默认为0,扫描结果由微信处理,1则直接返回扫描结果,
- // scanType: ['qrCode', 'barCode'], // 可以指定扫二维码还是一维码,默认二者都有
- // success: res => {
- // var result = res
- // .resultStr; // 当needResult 为 1 时,扫码返回的结果
- // var site = result.lastIndexOf('\/')
- // var params = result.substring(site + 1, result
- // .length)
- // this.code = window.encodeURIComponent(params)
- // let index = this.list.findIndex(item => item
- // .code == this.code)
- // if (index != -1) {
- // uni.showModal({
- // title: '错误提示',
- // content: '此码已添加,请勿重复扫描',
- // showCancel: false
- // })
- // } else {
- // this.getInfo(this.code)
- // }
- // }
- // })
- // })
- // } else {
- // uni.showModal({
- // title: '错误提示',
- // content: res.message || '获取信息失败',
- // showCancel: false
- // })
- // }
- // });
- // };
- // }
- }
- }
- </script>
- <style>
- page {
- background-color: #fff;
- }
- </style>
- <style lang="scss" scoped>
- .showTip {
- position: fixed;
- left: 0;
- right: 0;
- top: 30%;
- margin: auto;
- width: 648rpx;
- height: 368rpx;
- background: #FFFFFF;
- border-radius: 24rpx;
- z-index: 10000;
- display: flex;
- justify-content: space-between;
- align-items: center;
- flex-direction: column;
- padding-bottom: 34rpx;
- image {
- width: 180rpx;
- height: 136rpx;
- margin-top: -68rpx;
- }
- .title {
- font-size: 38rpx;
- font-weight: bold;
- color: #333333;
- }
- .remark {
- font-size: 34rpx;
- font-weight: 400;
- color: #333333;
- }
- .btn {
- display: flex;
- view {
- width: 242rpx;
- height: 88rpx;
- border-radius: 44rpx;
- text-align: center;
- line-height: 88rpx;
- font-size: 32rpx;
- font-weight: bold;
- }
- &_left {
- background: #F5F5F5;
- color: #333333;
- }
- &_right {
- margin-left: 24rpx;
- background: linear-gradient(93deg, #F30000 0%, #FE4815 100%);
- color: #fff;
- }
- }
- }
- .detailTop {
- padding: 24rpx 0 0 24rpx;
- display: flex;
- align-items: center;
- &_left {
- width: 136rpx;
- font-size: 34rpx;
- font-weight: bold;
- color: #333333;
- }
- &_right {
- width: 566rpx;
- height: 104rpx;
- background: #F8F8F8;
- border-radius: 8rpx;
- line-height: 104rpx;
- padding-left: 28rpx;
- color: #333;
- font-size: 32rpx;
- }
- }
- .detailMiddle {
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding: 0 10rpx;
- text {
- // display: flex;
- display: inline-block;
- width: 16%;
- text-align: center;
- line-height: 90rpx;
- font-size: 32rpx;
- font-weight: bold;
- }
- }
- .detailMiddleRed {
- display: flex;
- align-items: center;
- justify-content: space-between;
- background-color: #FFF4F3;
- // padding: 0 10rpx;
- text {
- display: flex;
- display: inline-block;
- width: 16%;
- text-align: center;
- line-height: 90rpx;
- font-size: 32rpx;
- font-weight: bold;
- color: #FB231F;
- }
- }
- .listBox {
- padding-bottom: 104rpx;
- // height: 1500rpx;
- .back {
- background-color: #F8F8F8;
- }
- &_item {
- display: flex;
- justify-content: space-between;
- align-items: center;
- padding: 0 24rpx;
- height: 104rpx;
- .left {
- font-weight: bold;
- font-size: 32rpx;
- }
- .gray {
- margin-left: 70rpx;
- // width: 80rpx;
- text-align: center;
- font-size: 32rpx;
- font-weight: bold;
- color: #999999;
- }
- .right {
- width: 132rpx;
- height: 64rpx;
- background: linear-gradient(141deg, #F30000 0%, #FE4815 100%);
- border-radius: 34rpx;
- line-height: 64rpx;
- text-align: center;
- color: #fff;
- font-size: 28rpx;
- }
- }
- }
- .fiexedEnd {
- position: fixed;
- left: 0;
- bottom: 0;
- width: 100%;
- height: 104rpx;
- background: #FFFFFF;
- box-shadow: 0rpx -4rpx 24rpx rgba(0, 0, 0, 0.1);
- padding: 0 72rpx 18rpx 72rpx;
- font-size: 32rpx;
- font-weight: bold;
- display: flex;
- justify-content: space-between;
- align-items: flex-end;
- &_red {
- width: 172rpx;
- height: 172rpx;
- background: linear-gradient(150deg, #FFAA01 0%, #FE0000 100%);
- box-shadow: 0px 6rpx 20rpx rgba(254, 34, 0, 0.43);
- border-radius: 50%;
- font-size: 40rpx;
- color: #fff;
- line-height: 172rpx;
- text-align: center;
- }
- &_title {
- margin-bottom: 12rpx;
- }
- }
- </style>
|