diff --git a/App.vue b/App.vue index 48bb5c7..0181ccc 100644 --- a/App.vue +++ b/App.vue @@ -31,7 +31,6 @@ }) } // #endif - this.initLog({ mch_id: 0 }) // 访问记录 @@ -39,7 +38,10 @@ setHeaderHeight(); }, onShow(options) { - + uni.hideTabBar() + }, + onLoad() { + uni.hideTabBar() }, onHide() { // console.log("App Hide"); diff --git a/api/modules/common.js b/api/modules/common.js index 3faebb0..5f12d44 100644 --- a/api/modules/common.js +++ b/api/modules/common.js @@ -143,7 +143,16 @@ export default { needLogin: true, }); }, - + + wechatPageH5(data) { + return request({ + url: "/common/wechatPageH5", + method: "GET", + data, + needLogin: true, + }); + }, + aliH5(data) { return request({ url: "/common/aliH5", @@ -161,7 +170,7 @@ export default { needLogin: true, }); }, - + getFlashMch(data) { return request({ url: "/common/FlashListMch", @@ -178,4 +187,95 @@ export default { needLogin: true, }); }, + + getAliCard(data = {}) { + return request({ + url: "/common/getAliCard", + method: "POST", + data, + needLogin: true, + }); + }, + + + getFootCat(data) { + return request({ + url: "/common/getFootCat", + method: "GET", + data, + needLogin: true, + }); + }, + getFootCatAll(data) { + return request({ + url: "/common/getFootCatAll", + method: "GET", + data, + needLogin: true, + }); + }, + getFootGoods(data) { + return request({ + url: "/common/getFootGoods", + method: "GET", + data, + needLogin: true, + }); + }, + goodsInfo(data) { + return request({ + url: "/goods/goodsInfo", + method: "POST", + data, + }); + }, + + getIsBusinessHours(data) { + return request({ + url: "/common/getIsBusinessHours", + method: "POST", + data, + needLogin: true, + }); + }, + DiningRoom(data) { + return request({ + url: "/goodFood/DiningRoom", + method: "POST", + data, + needLogin: true, + }); + }, + FoodOrderPreview(data) { + return request({ + url: "/order/FoodOrderPreview", + method: "GET", + data, + needLogin: true, + }); + }, + FoodPlaceOrder(data) { + return request({ + url: "/order/FoodPlaceOrder", + method: "POST", + data, + needLogin: true, + }); + }, + getFootOrder(data = {}) { + return request({ + url: "/common/getFootOrder", + method: "POST", + data, + needLogin: true, + }); + }, + getRen(data = {}) { + return request({ + url: "/common/getRen", + method: "POST", + data, + needLogin: true, + }); + }, }; \ No newline at end of file diff --git a/api/modules/user.js b/api/modules/user.js index 222b222..3d80070 100644 --- a/api/modules/user.js +++ b/api/modules/user.js @@ -11,6 +11,13 @@ export default { data, }); }, + wxH5Login(data) { + return request({ + url: "/auth/wxH5Login", + method: "POST", + data, + }); + }, // 手机号注册 regPhone(data) { return request({ @@ -174,5 +181,21 @@ export default { data, needLogin: true, }); - } + }, + openAliCard(data = {}) { + return request({ + url: "/user/openAliCard", + method: "POST", + data, + needLogin: true, + }); + }, + creatCard(data = {}) { + return request({ + url: "/user/creatCard", + method: "POST", + data, + needLogin: true, + }); + }, }; \ No newline at end of file diff --git a/components/login/logins.vue b/components/login/logins.vue index 5d6d8fe..aa1d52a 100644 --- a/components/login/logins.vue +++ b/components/login/logins.vue @@ -33,21 +33,31 @@ created() { if (this.wcCode) { this.actionLogin(this.wcCode, '', 1); - } - // 验证是否需要登录 - if (this.type == 2) { - this.isLogin() - } - // #ifdef H5 - // 如果是支付宝h5自动完成登陆 - if (this.type == 0) { - if (this.$utils.isInAliBrowser()) { - this.login() + } else { + // 验证是否需要登录 + if (this.type == 2) { + this.isLogin() } + // #ifdef H5 + // 如果是支付宝h5自动完成登陆 + if (this.type == 0) { + this.h5IsLogin() + } + // #endif } - // #endif + }, methods: { + async h5IsLogin() { + if (this.$utils.isInAliBrowser() || this.$utils.isInWeChatBrowser()) { + const res = await this.$api.user.isLogin(); + if (res.data.is_login > 0) { + this.$emit('isLogin') + } else { + this.login() + } + } + }, async login({ phone_code } = {}) { @@ -90,7 +100,6 @@ const res = await this.$api.common.aliH5(); // 获取微信应用的 appid const appid = res.data.appid; - ap.getAuthCode({ appId: appid, scopes: ['auth_base'], @@ -110,15 +119,18 @@ } else if (this.$utils.isInWeChatBrowser()) { // 微信h5登陆 // 从后端API获取微信H5相关信息 - const res = await this.$api.common.wechatH5(); + const res = await this.$api.common.wechatPageH5(); // 获取微信应用的 appid const appid = res.data.appid; + const component_appid = res.data.component_appid // 获取当前页面的重定向地址并进行编码 let redirect_uri = window.location.href; - redirect_uri = encodeURIComponent(redirect_uri); - // 构建微信授权链接,包含应用的appid、重定向地址等参数 - const wxAuthUrl = - `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appid}&redirect_uri=${redirect_uri}&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect`; + var fruits = redirect_uri.split("?"); + // console.log(fruits, 'fruits') + redirect_uri = encodeURIComponent(fruits[0]); + + // 构建微信授权链接,包含应用的appid、重定向地址等参数; + const wxAuthUrl = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appid}&redirect_uri=${redirect_uri}&response_type=code&scope=snsapi_base&state=STATE&component_appid=${component_appid}#wechat_redirect` // 通过重定向将用户导向微信授权页面 window.location.href = wxAuthUrl; return; @@ -153,7 +165,6 @@ user_info, store_id } = res.data; - uni.setStorageSync("token_" + store_id, token); uni.setStorageSync("user_info", user_info); if (this.type != 0) { @@ -166,7 +177,6 @@ this.backPage() return; } - uni.$u.toast(res.message); } catch (e) { uni.hideLoading(); @@ -187,7 +197,7 @@ backPage() { if (this.type == 0) { - + this.$emit('isLogin') } else if (this.type != 2) { setTimeout(() => { const backPage = uni.getStorageSync("backPage") diff --git a/components/login/logins11.vue b/components/login/logins11.vue new file mode 100644 index 0000000..e315e6e --- /dev/null +++ b/components/login/logins11.vue @@ -0,0 +1,207 @@ + + + \ No newline at end of file diff --git a/components/the/keyword.vue b/components/the/keyword.vue new file mode 100644 index 0000000..f34b399 --- /dev/null +++ b/components/the/keyword.vue @@ -0,0 +1,119 @@ + + + + + diff --git a/env.js b/env.js index 21519d4..108bb12 100644 --- a/env.js +++ b/env.js @@ -3,7 +3,8 @@ const env = { NETWORK_TIME_OUT: 15000, version: "0.1", store_id: 1, - mini_id: 0 + mini_id: 0, + is_page: 1 }; // #ifdef H5 // 生产环境 diff --git a/manifest.json b/manifest.json index a5dddec..c184945 100644 --- a/manifest.json +++ b/manifest.json @@ -1,5 +1,5 @@ { - "name" : "佰因商城", + "name" : "门店收银", "appid" : "__UNI__730E59B", "description" : "", "versionName" : "1.0.0", diff --git a/pages.json b/pages.json index 93089ca..561dbd3 100644 --- a/pages.json +++ b/pages.json @@ -12,6 +12,30 @@ } } }, + { + "path": "pages/card/index", + "style": { + "navigationStyle": "custom", + "navigationBarTitleText": "会员卡", + "enablePullDownRefresh": true, + "mp-alipay": { + "transparentTitle": "always", + "titlePenetrate": "YES" + } + } + }, + { + "path": "pages/card/loading", + "style": { + "navigationStyle": "custom", + "navigationBarTitleText": "会员卡", + "enablePullDownRefresh": true, + "mp-alipay": { + "transparentTitle": "always", + "titlePenetrate": "YES" + } + } + }, { "path": "pages/my/my", "style": { @@ -23,6 +47,24 @@ "titlePenetrate": "YES" } } + }, + { + "path": "pages/takeaway/index", + "style": { + "navigationBarTitleText": "点餐" + } + }, + { + "path": "pages/takeaway/orderAndSettlement/index", + "style": { + "navigationBarTitleText": "点餐" + } + }, + { + "path": "pages/takeaway/orderAndSettlement/edit", + "style": { + "navigationBarTitleText": "点餐" + } } ], "subPackages": [ @@ -96,6 +138,7 @@ "selectedColor": "#E2231A", "borderStyle": "black", "backgroundColor": "#fff", + "height": "0px", "list": [ { "pagePath": "pages/index/index", diff --git a/pages/card/index.vue b/pages/card/index.vue new file mode 100644 index 0000000..e295f48 --- /dev/null +++ b/pages/card/index.vue @@ -0,0 +1,74 @@ + + + + + \ No newline at end of file diff --git a/pages/card/loading.vue b/pages/card/loading.vue new file mode 100644 index 0000000..19eb5c6 --- /dev/null +++ b/pages/card/loading.vue @@ -0,0 +1,65 @@ + + + + + \ No newline at end of file diff --git a/pages/index/index.vue b/pages/index/index.vue index 6b0afc4..b894efd 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -21,28 +21,20 @@ }, data() { return { - + opt: {} } }, onLoad(opt) { - uni.hideTabBar({ - animation: true, - success: function (res) { - console.log(res); // { "success": true} - }, - fail: function (err) { - console.log(err); - } - }); + this.opt = opt + this.$nextTick(() => { + if (opt.auth_code) { + this.getData() + } + }) }, computed: { - shareData() { - return { - path: "/pages/index/index", - desc: "多彩时尚,一站式购物体验" - } - } + }, async onPullDownRefresh() { @@ -58,13 +50,10 @@ this.on_reach_bottom = true; }, onPullDownRefresh() { - this.getTemplate(); - setTimeout(function() { - uni.stopPullDownRefresh(); - }, 200); + }, methods: { - + } } diff --git a/pages/takeaway/compontents/goods.vue b/pages/takeaway/compontents/goods.vue new file mode 100644 index 0000000..b472a4b --- /dev/null +++ b/pages/takeaway/compontents/goods.vue @@ -0,0 +1,77 @@ + + + + + \ No newline at end of file diff --git a/pages/takeaway/compontents/page-banner.vue b/pages/takeaway/compontents/page-banner.vue new file mode 100644 index 0000000..88fb63a --- /dev/null +++ b/pages/takeaway/compontents/page-banner.vue @@ -0,0 +1,188 @@ + + + + + \ No newline at end of file diff --git a/pages/takeaway/compontents/page-detail.vue b/pages/takeaway/compontents/page-detail.vue new file mode 100644 index 0000000..97d4535 --- /dev/null +++ b/pages/takeaway/compontents/page-detail.vue @@ -0,0 +1,94 @@ + + + + + \ No newline at end of file diff --git a/pages/takeaway/compontents/page-info.vue b/pages/takeaway/compontents/page-info.vue new file mode 100644 index 0000000..692b9d0 --- /dev/null +++ b/pages/takeaway/compontents/page-info.vue @@ -0,0 +1,279 @@ + + + + \ No newline at end of file diff --git a/pages/takeaway/compontents/page-sku.vue b/pages/takeaway/compontents/page-sku.vue new file mode 100644 index 0000000..33b28f7 --- /dev/null +++ b/pages/takeaway/compontents/page-sku.vue @@ -0,0 +1,540 @@ + + + + + + + \ No newline at end of file diff --git a/pages/takeaway/compontents/smallMaterial.vue b/pages/takeaway/compontents/smallMaterial.vue new file mode 100644 index 0000000..5a98a0c --- /dev/null +++ b/pages/takeaway/compontents/smallMaterial.vue @@ -0,0 +1,244 @@ + + + + + \ No newline at end of file diff --git a/pages/takeaway/index - 副本 (2).vue b/pages/takeaway/index - 副本 (2).vue new file mode 100644 index 0000000..fbc0a10 --- /dev/null +++ b/pages/takeaway/index - 副本 (2).vue @@ -0,0 +1,792 @@ + + + + \ No newline at end of file diff --git a/pages/takeaway/index - 副本.vue b/pages/takeaway/index - 副本.vue new file mode 100644 index 0000000..9f6a00d --- /dev/null +++ b/pages/takeaway/index - 副本.vue @@ -0,0 +1,777 @@ + + + + \ No newline at end of file diff --git a/pages/takeaway/index.vue b/pages/takeaway/index.vue new file mode 100644 index 0000000..3002273 --- /dev/null +++ b/pages/takeaway/index.vue @@ -0,0 +1,680 @@ + + + + \ No newline at end of file diff --git a/pages/takeaway/orderAndSettlement/edit.vue b/pages/takeaway/orderAndSettlement/edit.vue new file mode 100644 index 0000000..b83b4bb --- /dev/null +++ b/pages/takeaway/orderAndSettlement/edit.vue @@ -0,0 +1,126 @@ + + + + + \ No newline at end of file diff --git a/pages/takeaway/orderAndSettlement/index.vue b/pages/takeaway/orderAndSettlement/index.vue new file mode 100644 index 0000000..fda93dc --- /dev/null +++ b/pages/takeaway/orderAndSettlement/index.vue @@ -0,0 +1,739 @@ + + + + + \ No newline at end of file diff --git a/static/image/bixuan.png b/static/image/bixuan.png new file mode 100644 index 0000000..0d913dd Binary files /dev/null and b/static/image/bixuan.png differ diff --git a/subPackages/inPersonToPay/index/index.vue b/subPackages/inPersonToPay/index/index.vue index f85f736..0f713df 100644 --- a/subPackages/inPersonToPay/index/index.vue +++ b/subPackages/inPersonToPay/index/index.vue @@ -8,18 +8,21 @@ - + {{ info.name }} - + - + - + + {{ total_price }} + + @@ -34,30 +37,11 @@ - - - - 微信 - - - - - - - - - 支付宝 - - - - - - - 微信 + 微信支付 @@ -65,7 +49,7 @@ - 支付宝 + 支付宝支付 @@ -73,10 +57,16 @@ - - - - + + + + + @@ -85,6 +75,7 @@ import coupons from '../compontents/coupons.vue'; import logins from '@/components/login/logins.vue' + import keyword from '@/components/the/keyword.vue' // #ifndef MP import wxConfig from '@/utils/wxConfig' @@ -94,7 +85,8 @@ components: { coupons, isPhone, - logins + logins, + keyword }, data() { return { @@ -108,7 +100,8 @@ payCurrent: false, coupon: [], activeCoupon: {}, - mch_id: 0 + mch_id: 0, + wcCode: -1 } }, computed: { @@ -122,34 +115,26 @@ } }, async onLoad(query) { - let qrCode = ''; - - // #ifdef MP-ALIPAY - let qrQuery = '' - if (query.query && query.query.qrCode) { - qrQuery = query.query.qrCode; // 存储二维码码 - } else { - qrQuery = uni.getStorageSync('qrcode') + if (query.wxcode) { + this.wcCode = query.wxcode + query.mch_id = uni.getStorageSync('pay_mch_id') + } else { + if (query.state) { + return uni.showModal({ + title: '提示', + content: '登录失败' + }) } - qrCode = decodeURIComponent(qrQuery || ''); // 适用于支付宝小程序 - // #endif - - // #ifdef MP-WEIXIN - qrCode = decodeURIComponent(query.q || ''); - // #endif - - // #ifdef MP - const params = this.$utils.oneValues(qrCode) - // #endif - - // #ifdef H5 - const params = query - // #endif - + this.wcCode = '' + if (query.mch_id > 0) { + uni.setStorageSync('pay_mch_id', query.mch_id) + } + } + let qrCode = ''; + const params = query const { mch_id } = params; - this.mch_id = mch_id || 0 this.$nextTick(() => { this.init() @@ -193,24 +178,29 @@ } this.coupon = res.data.coupon }, + valueChange(e) { + this.total_price += ('' + e) + this.formatInput() + }, + valueBackspace() { + let value = this.total_price.toString() + value = value.slice(0, -1) + this.total_price = value + }, formatInput() { if (this.total_price !== null) { - let value = this.total_price.toString(); - value = value.replace(/[^\d.]/g, ""); // 去掉非数字和小数点 - value = value.replace(/^\./g, ""); // 去掉开头的小数点 - value = value.replace(/\.{2,}/g, "."); // 去掉多余的小数点 - value = value.replace(".", "$#$").replace(/\./g, "").replace("$#$", "."); - // 将第一个小数点替换成分隔符 - value = parseFloat(value); - if (isNaN(value)) { - value = null; - } else { - value = value.toFixed(2); // 保留两位小数 + let value = this.total_price + let value_arr = value.toString().split('.') + if (value_arr.length > 1) { + var len = value_arr.pop().length; + if (len > 2) { + value = parseFloat(value); + value = value.toFixed(2); // 保留两位小数 + } } this.total_price = value; } }, - async pay(type) { if (this.submit()) return this.payCurrent = true @@ -272,9 +262,7 @@ order_no, order_type }) - break; - default: break; } @@ -323,6 +311,7 @@ if (res.data == -1) { return this.successSubmit(); } + let that = this wxConfig.init(["chooseWXPay"]).then(wx => { wx.chooseWXPay({ // 支付签名时间戳,注意微信jssdk中的所有使用timestamp字段均为小写。 @@ -333,20 +322,22 @@ signType: res.data.signType, // 签名算法 paySign: res.data.paySign, // 签名 success: function(res) { + console.log(res, 'success') if (res.err_msg == "get_brand_wcpay_request:ok" || res.err_Info == "success" || res.errMsg == "chooseWXPay:ok") { - this.successSubmit(); + that.successSubmit(); } else { - this.failSubmit(); + that.failSubmit(); } }, complete: function(err) { + console.log(res, 'complete') if (res.err_msg == "get_brand_wcpay_request:ok" || res.err_Info == "success" || res.errMsg == "chooseWXPay:ok" || res.errMsg == "getBrandWCPayRequest:ok") { - this.successSubmit(); + that.successSubmit(); } else { - this.failSubmit(); + that.failSubmit(); } }, }) @@ -480,7 +471,7 @@ setTimeout(() => { this.toUrl('/subPackages/inPersonToPay/result/index?price=' + this.total_price + '&mch_id=' + - this.mch_id) + this.mch_id, 'reLaunch') uni.removeStorageSync("支付" + this.mch_id) this.total_price = "" this.payCurrent = false @@ -505,6 +496,15 @@