From 83f1e822c1e633b738c437f363ddf3bfef9883ca Mon Sep 17 00:00:00 2001 From: guoxing <1369478551@qq.com> Date: Tue, 28 Nov 2023 11:38:33 +0800 Subject: [PATCH] 2023-11-28 --- common/app.scss | 130 +++ common/config.js | 4 +- common/getQuery.js | 22 + common/mixin.js | 7 + common/props.js | 2 + common/req.js | 16 + common/request.api.js | 11 + main.js | 5 + manifest.json | 2 +- pages.json | 35 +- pages/card/card_bind.vue | 11 +- pages/card/card_bind2.vue | 150 +++ pages/card/card_booking.vue | 38 +- pages/card/card_detail.vue | 8 +- pages/card/card_record.vue | 99 ++ pages/card/card_record_detail.vue | 138 +++ pages/login/fwxy.vue | 1479 +++++++++++++++++++++++++ pages/login/yszc.vue | 334 ++++++ pages/record/recordList.vue | 115 ++ utils/request/index.js | 13 + utils/request/requestInterceptors.js | 35 + utils/request/responseInterceptors.js | 130 +++ 22 files changed, 2772 insertions(+), 12 deletions(-) create mode 100644 common/app.scss create mode 100644 common/getQuery.js create mode 100644 common/mixin.js create mode 100644 common/props.js create mode 100644 common/req.js create mode 100644 pages/card/card_bind2.vue create mode 100644 pages/card/card_record.vue create mode 100644 pages/card/card_record_detail.vue create mode 100644 pages/login/fwxy.vue create mode 100644 pages/login/yszc.vue create mode 100644 pages/record/recordList.vue create mode 100644 utils/request/index.js create mode 100644 utils/request/requestInterceptors.js create mode 100644 utils/request/responseInterceptors.js diff --git a/common/app.scss b/common/app.scss new file mode 100644 index 0000000..415d752 --- /dev/null +++ b/common/app.scss @@ -0,0 +1,130 @@ +/** + * 这里是uni-app内置的常用样式变量 + * + * uni-app 官方扩展插件及插件市场(https://ext.dcloud.net.cn)上很多三方插件均使用了这些样式变量 + * 如果你是插件开发者,建议你使用scss预处理,并在插件代码中直接使用这些变量(无需 import 这个文件),方便用户通过搭积木的方式开发整体风格一致的App + * + */ + +/** + * 如果你是App开发者(插件使用者),你可以通过修改这些变量来定制自己的插件主题,实现自定义主题功能 + * + * 如果你的项目同样使用了scss预处理,你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件 + */ + +/* 颜色变量 */ + +/* 行为相关颜色 */ +$uni-color-primary: #007aff; +$uni-color-success: #4cd964; +$uni-color-warning: #f0ad4e; +$uni-color-error: #dd524d; + +/* 文字基本颜色 */ +$uni-text-color: #333; //基本色 +$uni-text-color-inverse: #fff; //反色 +$uni-text-color-grey: #999; //辅助灰色,如加载更多的提示信息 +$uni-text-color-placeholder: #808080; +$uni-text-color-disable: #c0c0c0; + +/* 背景颜色 */ +$uni-bg-color: #ffffff; +$uni-bg-color-grey: #f8f8f8; +$uni-bg-color-hover: #f1f1f1; //点击状态颜色 +$uni-bg-color-mask: rgba(0, 0, 0, 0.4); //遮罩颜色 + +/* 边框颜色 */ +$uni-border-color: #c8c7cc; + +/* 尺寸变量 */ + +/* 文字尺寸 */ +$uni-font-size-sm: 12px; +$uni-font-size-base: 14px; +$uni-font-size-lg: 16; + +/* 图片尺寸 */ +$uni-img-size-sm: 20px; +$uni-img-size-base: 26px; +$uni-img-size-lg: 40px; + +/* Border Radius */ +$uni-border-radius-sm: 2px; +$uni-border-radius-base: 3px; +$uni-border-radius-lg: 6px; +$uni-border-radius-circle: 50%; + +/* 水平间距 */ +$uni-spacing-row-sm: 5px; +$uni-spacing-row-base: 10px; +$uni-spacing-row-lg: 15px; + +/* 垂直间距 */ +$uni-spacing-col-sm: 4px; +$uni-spacing-col-base: 8px; +$uni-spacing-col-lg: 12px; + +/* 透明度 */ +$uni-opacity-disabled: 0.3; // 组件禁用态的透明度 + +/* 文章场景相关 */ +$uni-color-title: #2c405a; // 文章标题颜色 +$uni-font-size-title: 20px; +$uni-color-subtitle: #555555; // 二级标题颜色 +$uni-font-size-subtitle: 26px; +$uni-color-paragraph: #3f536e; // 文章段落颜色 +$uni-font-size-paragraph: 15px; + +/** + * 下面为当前APP自己定义的公共样式 + */ +.app-container { + padding: 20px; + font-size: 14px; + line-height: 24px; +} + +.u-block { + padding: 14px; + &__section { + margin-bottom: 10px; + } + &__title { + margin-top: 10px; + font-size: 15px; + color: $u-content-color; + margin-bottom: 10px; + } + &__flex { + /* #ifndef APP-NVUE */ + display: flex; + /* #endif */ + } +} + +// 使用了cell组件的icon图片样式 +.u-cell-icon { + width: 36rpx; + height: 36rpx; + margin-right: 8rpx; +} + +.u-page { + padding: 15px 15px 40px 15px; +} + +.u-demo-block { + flex: 1; + margin-bottom: 23px; + + &__content { + @include flex(column); + } + + &__title { + font-size: 14px; + color: rgb(143, 156, 162); + margin-bottom: 8px; + @include flex; + } +} diff --git a/common/config.js b/common/config.js index 510b5a8..5c1e14c 100644 --- a/common/config.js +++ b/common/config.js @@ -6,8 +6,8 @@ * loginTimeoutPage = "/pages/login/index", // 登录超时或失效的情况下,跳转到的登录页面 */ module.exports = { - baseUrl: 'http://192.168.2.112:7201', - // baseUrl: 'https://supervise.yxtsoft.com/lpkapi', + // baseUrl: 'http://192.168.2.110:7201', + baseUrl: 'https://supervise.yxtsoft.com/lpkapi', // baseUrl: 'http://jianguan.yyundong.com/api', tokenName: "Authorization", // 请求头中token的名字,与服务器端对应 loginTimeoutCode: "5001", // 登录超时或失效的情况下,服务器端返回的错误码 diff --git a/common/getQuery.js b/common/getQuery.js new file mode 100644 index 0000000..ab91403 --- /dev/null +++ b/common/getQuery.js @@ -0,0 +1,22 @@ +/** + * getQueryString 二维码参数转换提取 + * 参数 + * url 二维码参数 + * name 需要提取的参数 + */ +function getQueryString(url, name) { + let reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)",'i'); + var r = url.substr(1).match(reg) + + if (r != null) { + + return r[2] + + } + + return null; +} + +export { + getQueryString +} \ No newline at end of file diff --git a/common/mixin.js b/common/mixin.js new file mode 100644 index 0000000..b6a4eee --- /dev/null +++ b/common/mixin.js @@ -0,0 +1,7 @@ +export default { + data() { + return { + + } + } +} diff --git a/common/props.js b/common/props.js new file mode 100644 index 0000000..9c1ef07 --- /dev/null +++ b/common/props.js @@ -0,0 +1,2 @@ +uni.$u.props.gap.bgColor = '#f3f4f6' +uni.$u.props.gap.height = '10' diff --git a/common/req.js b/common/req.js new file mode 100644 index 0000000..4b02b48 --- /dev/null +++ b/common/req.js @@ -0,0 +1,16 @@ +const { + http +} = uni.$u + +export default { + login: (params, config = {}) => http.post('/login', params, { + custom: { + catchError: true, + showFailMessage: true + } + }), + sayhello: (params = {}) => http.get("/sayb", params), + + // 查看预警信息 + selectBusinessRiskInfo: (params = {}) => http.post("/v1/businessData/selectBusinessRiskInfo", params) +} diff --git a/common/request.api.js b/common/request.api.js index 4ec82d4..64b9f35 100644 --- a/common/request.api.js +++ b/common/request.api.js @@ -4,9 +4,20 @@ export default { login: (params = {}) => request.post("/wxmpapi/sysuser/login", params), wxBindMobile: (params = {}) => request.post("/lpkcustomer/wxBindMobile", params), // 不显示loading true + // 提货卡列表 cardList: (params = {}) => request.post("/lpkgiftcard/gifCardByCustomerSid", params, {}, {}, true), + // 提货卡详情 cardDetail: (params = {}) => request.get("/lpkgiftcard/getGifCardBySid/" + params, params, {}, {}, true), + // 提货卡预约初始化 cardBooking: (params = {}) => request.get("/lpkgiftcard/getReservationBySid/" + params, params, {}, {}, true), + // 提货卡预约保存 cardBookingSave: (params = {}) => request.post("/lpksreservoorder/submission", params), + // 绑定提货卡 cardBind: (params = {}) => request.post("/lpkgiftcard/bindCard", params), + // 单一提货卡预约记录 + orderByCardSid: (params = {}) => request.get("/lpksreservoorder/orderByCardSid/"+ params, params, {}, {}, true), + // 预约记录 + orderListByUserSid: (params = {}) => request.post("/lpksreservoorder/orderListByUserSid/", params, {}, {}, true), + // 预约记录详情 + orderDetails: (params = {}) => request.get("/lpksreservoorder/orderDetails/"+params, params, {}, {}, true), } \ No newline at end of file diff --git a/main.js b/main.js index ab4974b..f51ce1c 100644 --- a/main.js +++ b/main.js @@ -17,6 +17,11 @@ import { Vue.prototype.stringIsEmpty = stringIsEmpty Vue.prototype.stringIsNotEmpty = stringIsNotEmpty +import { + getQueryString, +} from "@/common/getQuery.js" +Vue.prototype.getQueryString = getQueryString + import { shortToast, longToast diff --git a/manifest.json b/manifest.json index c2b91d6..5a806f3 100644 --- a/manifest.json +++ b/manifest.json @@ -50,7 +50,7 @@ "quickapp" : {}, /* 小程序特有相关 */ "mp-weixin" : { - "appid" : "wx4724e3a3c27f36b5", + "appid" : "wx97c0a62c6d65207f", "setting" : { "urlCheck" : false }, diff --git a/pages.json b/pages.json index 9786f4b..0cf540b 100644 --- a/pages.json +++ b/pages.json @@ -26,12 +26,27 @@ "enablePullDownRefresh": false } }, + { + "path": "pages/card/card_record", + "style": { + "navigationBarTitleText": "预约记录" + } + }, { "path": "pages/card/card_bind", "style": { "navigationBarTitleText": "绑定礼包卡", "enablePullDownRefresh": false } + }, + + // 扫码进入 + { + "path": "pages/card/card_bind2", + "style": { + "navigationBarTitleText": "绑定礼包卡", + "enablePullDownRefresh": false + } }, { "path": "pages/index/BindPhone", "style": { @@ -51,7 +66,23 @@ "scrollIndicator": false //禁用原生导航栏, } } + }, + { + "path" : "pages/card/card_record_detail", + "style" : + { + "navigationBarTitleText" : "预约详情", + "enablePullDownRefresh" : false + } + }, + { + "path" : "pages/record/recordList", + "style" : + { + "navigationBarTitleText" : "预约记录" + } } + ], "globalStyle": { "navigationBarTextStyle": "black", @@ -70,8 +101,8 @@ "iconPath": "static/ze_bag_1.png", "selectedIconPath": "static/ze_bag2.png" }, { - "pagePath": "pages/home/UserFragment", - "text": "兑换记录", + "pagePath": "pages/record/recordList", + "text": "预约记录", "iconPath": "static/ze_underway1.png", "selectedIconPath": "static/ze_underway2.png" }] diff --git a/pages/card/card_bind.vue b/pages/card/card_bind.vue index faf4fd4..c09d060 100644 --- a/pages/card/card_bind.vue +++ b/pages/card/card_bind.vue @@ -44,10 +44,10 @@ this.page.customerSid = getApp().globalData.sid }, methods: { - onKeyInput1: function(event) { + onKeyInput1(event) { this.page.code = event.target.value }, - onKeyInput2: function(event) { + onKeyInput2(event) { this.page.codeKey = event.target.value }, scan() { @@ -55,8 +55,8 @@ let _this = this uni.scanCode({ onlyFromCamera: true, - success: function(res) { - _this.page.cardNum = res.result.substring(res.result.length - 20, res.result.length) + success(res) { + _this.page.code = res.result.substring(res.result.length - 20, res.result.length) } }); }, @@ -65,6 +65,7 @@ this.shortToast('请输入或扫描20位提货编码') return } + if (this.stringIsEmpty(this.page.codeKey) || this.page.codeKey.length != 6) { this.shortToast('请输入6位提货密码') return @@ -74,7 +75,7 @@ uni.navigateBack() uni.$emit('order', {}) }).catch(e => { - _this.shortToast('发生异常') + _this.longToast(e.msg) }) } } diff --git a/pages/card/card_bind2.vue b/pages/card/card_bind2.vue new file mode 100644 index 0000000..975b5ca --- /dev/null +++ b/pages/card/card_bind2.vue @@ -0,0 +1,150 @@ + + + + + \ No newline at end of file diff --git a/pages/card/card_booking.vue b/pages/card/card_booking.vue index 45a88f7..63a3806 100644 --- a/pages/card/card_booking.vue +++ b/pages/card/card_booking.vue @@ -38,6 +38,20 @@ + + 提货人员 + + + + 手机号码 + + @@ -91,7 +105,9 @@ showRecord: false, goodsVos: [], value: "", - select: [] + select: [], + userName:"", + userPhone:"", } } }, @@ -100,6 +116,12 @@ this.request() }, methods: { + onKeyInput1: function(event) { + this.data.userName = event.target.value + }, + onKeyInput2: function(event) { + this.data.userPhone = event.target.value + }, showing(e) { this.page.showTextView = e }, @@ -127,6 +149,20 @@ this.shortToast('请选择提货时间') return } + if (this.stringIsEmpty(this.data.userName)) { + this.shortToast('请输入提货人员') + return + } + if (this.stringIsEmpty(this.data.userPhone)) { + this.shortToast('请输入手机号码') + return + } + if (this.data.userPhone.length!=11) { + this.shortToast('手机号码格式不对') + return + } + + let num = 0; for (var i = 0; i < this.data.goodsVos.length; i++) { num += Number(this.data.goodsVos[i].select); diff --git a/pages/card/card_detail.vue b/pages/card/card_detail.vue index 3c80699..0f12ed2 100644 --- a/pages/card/card_detail.vue +++ b/pages/card/card_detail.vue @@ -53,7 +53,8 @@ - + 预约记录 预约提货 @@ -109,6 +110,11 @@ }) }) }, + showRecord(sid) { + uni.navigateTo({ + url: '/pages/card/card_record?sid=' + sid + }) + }, booking(sid) { uni.navigateTo({ url: '/pages/card/card_booking?sid=' + sid diff --git a/pages/card/card_record.vue b/pages/card/card_record.vue new file mode 100644 index 0000000..1d98d02 --- /dev/null +++ b/pages/card/card_record.vue @@ -0,0 +1,99 @@ + + + + + \ No newline at end of file diff --git a/pages/card/card_record_detail.vue b/pages/card/card_record_detail.vue new file mode 100644 index 0000000..c78328c --- /dev/null +++ b/pages/card/card_record_detail.vue @@ -0,0 +1,138 @@ + + + + + \ No newline at end of file diff --git a/pages/login/fwxy.vue b/pages/login/fwxy.vue new file mode 100644 index 0000000..eaf5c70 --- /dev/null +++ b/pages/login/fwxy.vue @@ -0,0 +1,1479 @@ + + + + + diff --git a/pages/login/yszc.vue b/pages/login/yszc.vue new file mode 100644 index 0000000..4a4f531 --- /dev/null +++ b/pages/login/yszc.vue @@ -0,0 +1,334 @@ + + + + + diff --git a/pages/record/recordList.vue b/pages/record/recordList.vue new file mode 100644 index 0000000..7c0ad95 --- /dev/null +++ b/pages/record/recordList.vue @@ -0,0 +1,115 @@ + + + + + \ No newline at end of file diff --git a/utils/request/index.js b/utils/request/index.js new file mode 100644 index 0000000..6658821 --- /dev/null +++ b/utils/request/index.js @@ -0,0 +1,13 @@ +// 引入配置 +import config from '@/common/config' +// 初始化请求配置 +uni.$u.http.setConfig((defaultConfig) => { + /* defaultConfig 为默认全局配置 */ + defaultConfig.baseURL = config.baseUrl /* 根域名 */ + return defaultConfig +}) + +module.exports = (vm) => { + require('./requestInterceptors')(vm) + require('./responseInterceptors')(vm) +} diff --git a/utils/request/requestInterceptors.js b/utils/request/requestInterceptors.js new file mode 100644 index 0000000..30c5994 --- /dev/null +++ b/utils/request/requestInterceptors.js @@ -0,0 +1,35 @@ +import conf from "@/common/config.js" +import token from '@/utils/auth.token.js' +/** + * 请求拦截 + * @param {Object} http + */ +module.exports = (vm) => { + uni.$u.http.interceptors.request.use((config) => { // 可使用async await 做异步操作 + // 初始化请求拦截器时,会执行此方法,此时data为undefined,赋予默认{} + config.data = config.data || {} + // 可以在此通过vm引用vuex中的变量,具体值在vm.$store.state中 + // console.log(vm.$store.state); + + // 设置请求头中token的名字,以及token的值 + let _token = token.getToken() + let _tokenName = 'Authorization' + if (conf.tokenName) { + _tokenName = conf.tokenName + } + config.header[_tokenName] = _token + + // 设置针对响应结果的处理方式 + let _cus = { + showLoading: true, // 是否显示加载等待框 + loadingTitle: '加载中', // 加载等待框的提示文字 + showFailMessage: true, // 返回失败信息是否显示 + catchError: true, // 是否集中管理Catch, + } + Object.assign(_cus, config.custom) + config.custom = _cus + + return config + }, (config) => // 可使用async await 做异步操作 + Promise.reject(config)) +} diff --git a/utils/request/responseInterceptors.js b/utils/request/responseInterceptors.js new file mode 100644 index 0000000..3650e9c --- /dev/null +++ b/utils/request/responseInterceptors.js @@ -0,0 +1,130 @@ +import conf from "@/common/config.js" +/** + * 响应拦截 + * @param {Object} http + */ +module.exports = (vm) => { + uni.$u.http.interceptors.response.use((response) => { + /* 对响应成功做点什么 可使用async await 做异步操作*/ + + // 自定义参数 + let _cus = { + showLoading: true, // 是否显示加载等待框 + loadingTitle: '加载中', // 加载等待框的提示文字 + showFailMessage: true, // 返回失败信息是否显示 + catchError: true, // 是否集中管理Catch, + } + if (response.config && response.config.custom) + Object.assign(_cus, response.config.custom) + + if (200 == response.statusCode) { + let data = response.data + if (_cus.catchError) { + if (data.success) { + return data.data + } else { + let loginTimeoutCode = "5000" + let loginTimeoutPage = "/pages/login/index" + if (conf.loginTimeoutCode) { + loginTimeoutCode = "" + conf.loginTimeoutCode + } + if (conf.loginTimeoutPage) { + loginTimeoutPage = conf.loginTimeoutPage + } + if (loginTimeoutCode === data.code) { + uni.showModal({ + title: '提示', + content: '登录过期或失效,请重新登录!', + showCancel: false, + success: function(res) { + uni.reLaunch({ + url: loginTimeoutPage + }) + } + }); + } else { + if (_cus.showFailMessage) { + uni.showToast({ + title: data.msg, + icon: 'none', + duration: 2000, + }) + } + } + return Promise.reject(data) + } + } else { + return data + } + } else { + console.log('response.statusCode--', response) + let em = { + "code": "" + response.statusCode, + "data": "", + "msg": "网络请求失败~", + "success": false, + "timestamp": new Date().getTime() + } + if (res.data) { + em.msg = res.data + } + if (_cus.showFailMessage) { + uni.showToast({ + title: em.msg, + icon: 'none', + duration: 2000, + }) + } + return Promise.reject(em) + } + + // const data = response.data + // if (data.code !== 200) { // 服务端返回的状态码不等于200,则reject() + // // 如果没有显式定义custom的toast参数为false的话,默认对报错进行toast弹出提示 + // if (custom.toast !== false) { + // uni.$u.toast(data.message) + // } + // // 如果需要catch返回,则进行reject + // if (custom?.catch) { + // return Promise.reject(data) + // } else { + // // 否则返回一个pending中的promise + // return new Promise(() => {}) + // } + // } + // return data.data || {} + }, (error) => { + console.log('request-fail', error) + let _opts = { + showLoading: true, // 是否显示加载等待框 + loadingTitle: '加载中', // 加载等待框的提示文字 + showFailMessage: true, // 返回失败信息是否显示 + catchError: true, // 是否集中管理Catch, + } + if (error.config && error.config.custom) + Object.assign(_opts, response.config.custom) + let em = { + "code": "600", + "data": "", + "msg": "网络请求失败~", + "success": false, + "timestamp": new Date().getTime() + } + if (404 == error.statusCode) { + em.code = "404" + em.msg = "404,请求地址错误" + } + if (500 == error.statusCode) { + em.code = "500" + em.msg = "500,内部服务错误" + } + if (_opts.showFailMessage) { + uni.showToast({ + title: em.msg, + icon: 'none', + duration: 2000, + }) + } + return Promise.reject(em) + }) +}