Commit 55374e15 by 宋冰琦

修改toast文案 修改头像昵称获取方式

parent 546e7ac8
import App from './App'; import App from "./App";
//引入vuex //引入vuex
import store from './store'; import store from "./store";
import utils from './utils/utils'; import utils from "./utils/utils";
// console.log(Vue.$u,22) // console.log(Vue.$u,22)
// 需要在Vue.use(uView)之后执行 // 需要在Vue.use(uView)之后执行
// #ifndef VUE3 // #ifndef VUE3
import Vue from 'vue'; import Vue from "vue";
import Vuex from 'vuex' import Vuex from "vuex";
import uView from 'uview-ui'; import uView from "uview-ui";
import User from '@/request/user'; import User from "@/request/user";
// main.js // main.js
import initToast from "@/components/bocft-toast/initToast.js" import initToast from "@/components/bocft-toast/initToast.js";
import showToast from "@/components/bocft-toast/bocft-toast.vue" import showToast from "@/components/bocft-toast/bocft-toast.vue";
import taBar from "@/components/tabBar/tabBar.vue" import taBar from "@/components/tabBar/tabBar.vue";
initToast(Vue); initToast(Vue);
Vue.component('show-toast',showToast); Vue.component("show-toast", showToast);
Vue.component('taBar',taBar); Vue.component("taBar", taBar);
Vue.use(uView); Vue.use(uView);
Vue.prototype.$utils = utils; Vue.prototype.$utils = utils;
Vue.prototype.setPrice = (price) => price && Number(price).toFixed(2); Vue.prototype.setPrice = (price) => price && Number(price).toFixed(2);
Vue.prototype.loginByPhoneNumber = (e) => { Vue.prototype.loginByPhoneNumber = (e) => {
if (e.detail.errMsg == 'getPhoneNumber:ok') { if (e.detail.errMsg == "getPhoneNumber:ok") {
User.getPhoneNumber(e); User.getPhoneNumber(e);
} else if (e.detail.errMsg == 'getPhoneNumber:fail user deny') { } else if (e.detail.errMsg == "getPhoneNumber:fail user deny") {
uni.showToast({ title: '已拒绝手机号授权', icon: 'error' }); uni.showToast({
title: "已拒绝手机号授权,请同意授权",
icon: "error",
});
} }
}; };
Vue.config.productionTip = false; Vue.config.productionTip = false;
App.mpType = 'app'; App.mpType = "app";
const app = new Vue({ const app = new Vue({
...App, ...App,
store, store,
}); });
export default app export default app;
app.$mount(); app.$mount();
require('./request/index')(app); require("./request/index")(app);
// #endif // #endif
// #ifdef VUE3 // #ifdef VUE3
import { createSSRApp } from 'vue'; import { createSSRApp } from "vue";
export function createApp() { export function createApp() {
const app = createSSRApp(App); const app = createSSRApp(App);
return { return {
......
import { $EventBus } from '@/utils/EventBus'; import { $EventBus } from "@/utils/EventBus";
import context from '../../main.js' import context from "../../main.js";
import Order from '@/request/order/index.js' import Order from "@/request/order/index.js";
export default { export default {
// 获取菜单列表 // 获取菜单列表
getMenuList(id) { getMenuList(id) {
return uni.$u.http return uni.$u.http
.get('/weixin/infoByShop', { .get("/weixin/infoByShop", {
params: { params: {
shopId: id, shopId: id,
}, },
...@@ -14,24 +14,27 @@ export default { ...@@ -14,24 +14,27 @@ export default {
return res; return res;
}) })
.catch((err) => { .catch((err) => {
context.showToast({ title: '服务器错误', icon: 'none' }); context.showToast({
title: "哎哟!刚刚走神了,请退出后重进",
icon: "none",
});
}); });
}, },
// 获取点单屏幕的订单信息 // 获取点单屏幕的订单信息
getScreenShopCar(key, location, sendData) { getScreenShopCar(key, location, sendData) {
return uni.$u.http return uni.$u.http
.post('/application/getData', { .post("/application/getData", {
key, key,
location, location,
...sendData ...sendData,
}) })
.then((res) => { .then((res) => {
return res; return res;
}) })
.catch((err) => { .catch((err) => {
context.showToast({ context.showToast({
title: '服务器错误', title: "哎哟!刚刚走神了,请退出后重进",
icon: 'none', icon: "none",
}); });
return err; return err;
}); });
...@@ -39,37 +42,38 @@ export default { ...@@ -39,37 +42,38 @@ export default {
// 下单获取预支付订单 // 下单获取预支付订单
saveReserve(data) { saveReserve(data) {
return uni.$u.http return uni.$u.http
.post('/order', data) .post("/order", data)
.then((res) => { .then((res) => {
return res; return res;
}) })
.catch((err) => { }); .catch((err) => {});
}, },
// saveReserve 为业务接口 // saveReserve 为业务接口
requestPayment(data, oldData, buyType, agreeTerms) { requestPayment(data, oldData, buyType, agreeTerms) {
// res为调起微信支付所需参数 // res为调起微信支付所需参数
// 调起微信支付 // 调起微信支付
if(data.appId) { if (data.appId) {
const { switchTab = true, callBack } = data const { switchTab = true, callBack } = data;
uni.requestPayment({ uni.requestPayment({
provider: 'wxpay', // 服务提提供商微信支付 provider: "wxpay", // 服务提提供商微信支付
timeStamp: data.timeStamp, // 时间戳 timeStamp: data.timeStamp, // 时间戳
nonceStr: data.nonceStr, // 随机字符串 nonceStr: data.nonceStr, // 随机字符串
package: data.package, package: data.package,
signType: data.signType || 'MD5', // 签名算法 signType: data.signType || "MD5", // 签名算法
paySign: data.paySign, // 签名 paySign: data.paySign, // 签名
success: async function (res) { success: async function (res) {
if (res.errMsg == 'requestPayment:ok') { if (res.errMsg == "requestPayment:ok") {
// 删除购物车数据后重新放回购物车 // 删除购物车数据后重新放回购物车
uni.setStorageSync('shopCarInfo', []); uni.setStorageSync("shopCarInfo", []);
$EventBus.$emit('updateCar'); $EventBus.$emit("updateCar");
uni.setStorageSync('orderId', data.orderId); uni.setStorageSync("orderId", data.orderId);
if(agreeTerms)uni.setStorageSync('TermsStatus',true) if (agreeTerms) uni.setStorageSync("TermsStatus", true);
if(switchTab){ if (switchTab) {
let url = '/orderSubPackage/pages/orderInfo/index?from=settlement' let url =
uni.navigateTo({ url }) "/orderSubPackage/pages/orderInfo/index?from=settlement";
}else{ uni.navigateTo({ url });
callBack() } else {
callBack();
} }
} }
...@@ -77,53 +81,52 @@ export default { ...@@ -77,53 +81,52 @@ export default {
}, },
fail: async function (err) { fail: async function (err) {
context.showToast({ context.showToast({
title: '支付失败', title: "支付失败,再试一试!",
icon: 'error', icon: "error",
}); });
uni.setStorageSync('shopCarInfo', []); uni.setStorageSync("shopCarInfo", []);
$EventBus.$emit('updateCar'); $EventBus.$emit("updateCar");
uni.setStorageSync('orderId', data.orderId); uni.setStorageSync("orderId", data.orderId);
if(switchTab){ if (switchTab) {
let url = '/orderSubPackage/pages/orderInfo/index?from=settlement' let url = "/orderSubPackage/pages/orderInfo/index?from=settlement";
uni.navigateTo({ url }) uni.navigateTo({ url });
}else{ } else {
callBack() callBack();
} }
}, },
}); });
}else{ } else {
uni.setStorageSync('orderId', data); uni.setStorageSync("orderId", data);
let url = '/orderSubPackage/pages/orderInfo/index?from=settlement' let url = "/orderSubPackage/pages/orderInfo/index?from=settlement";
uni.navigateTo({ url }) uni.navigateTo({ url });
} }
}, },
// 优惠卷信息接口 // 优惠卷信息接口
requestTicketList(data){ requestTicketList(data) {
return uni.$u.http return uni.$u.http
.post('/app/order/coupon/info', data) .post("/app/order/coupon/info", data)
.then((res) => { .then((res) => {
return res; return res;
}) })
.catch((err) => { .catch((err) => {
context.showToast({ context.showToast({
title: '服务器错误', title: "哎哟!刚刚走神了,请退出后重进",
icon: 'none', icon: "none",
}); });
return err; return err;
}); });
}, },
// 下单页面优惠卷可用数量 // 下单页面优惠卷可用数量
requestTicketNum(data){ requestTicketNum(data) {
return uni.$u.http return uni.$u.http
.post('/app/order/coupon/fitable-count', data) .post("/app/order/coupon/fitable-count", data)
.then((res) => { .then((res) => {
return res; return res;
}) })
.catch((err) => { .catch((err) => {
context.showToast({ context.showToast({
title: '服务器错误', title: "哎哟!刚刚走神了,请退出后重进",
icon: 'none', icon: "none",
}); });
return err; return err;
}); });
...@@ -131,16 +134,16 @@ export default { ...@@ -131,16 +134,16 @@ export default {
// 首页调用发送优惠券接口 // 首页调用发送优惠券接口
sendUserCoupon(data) { sendUserCoupon(data) {
return uni.$u.http return uni.$u.http
.post('/v1/issue/user/coupon', data) .post("/v1/issue/user/coupon", data)
.then((res) => { .then((res) => {
return res; return res;
}) })
.catch((err) => { .catch((err) => {
context.showToast({ context.showToast({
title: '服务器错误', title: "哎哟!刚刚走神了,请退出后重进",
icon: 'none', icon: "none",
}); });
return err; return err;
}); });
} },
}; };
import context from '../../main.js' import context from "../../main.js";
export default { export default {
getList(id) {}, getList(id) {},
getMsg() { getMsg() {
return uni.$u.http return uni.$u.http
.get('/system/message/list', {}) .get("/system/message/list", {})
.then((res) => { .then((res) => {
return res; return res;
}) })
.catch((err) => { .catch((err) => {
context.showToast({ title: '服务器错误', icon: 'none' }); context.showToast({
title: "哎哟!刚刚走神了,请退出后重进",
icon: "none",
});
}); });
}, },
read(data) { read(data) {
return uni.$u.http return uni.$u.http
.put('/system/message', data) .put("/system/message", data)
.then((res) => { .then((res) => {
return res; return res;
}) })
.catch((err) => { .catch((err) => {
context.showToast({ title: '服务器错误', icon: 'none' }); context.showToast({
title: "哎哟!刚刚走神了,请退出后重进",
icon: "none",
});
}); });
}, },
getMessageCount() { getMessageCount() {
return uni.$u.http return uni.$u.http
.get('/app/getMessageCount', {}) .get("/app/getMessageCount", {})
.then((res) => { .then((res) => {
return res; return res;
}) })
.catch((err) => { .catch((err) => {
context.showToast({ title: '服务器错误', icon: 'none' }); context.showToast({
title: "哎哟!刚刚走神了,请退出后重进",
icon: "none",
});
}); });
}, },
// 获取用户优惠卷列表 // 获取用户优惠卷列表
...@@ -39,7 +48,10 @@ export default { ...@@ -39,7 +48,10 @@ export default {
return res; return res;
}) })
.catch((err) => { .catch((err) => {
context.showToast({ title: '服务器错误', icon: 'none' }); context.showToast({
title: "哎哟!刚刚走神了,请退出后重进",
icon: "none",
});
}); });
}, },
// 获取用户信息 // 获取用户信息
...@@ -50,7 +62,10 @@ export default { ...@@ -50,7 +62,10 @@ export default {
return res; return res;
}) })
.catch((err) => { .catch((err) => {
context.showToast({ title: '服务器错误', icon: 'none' }); context.showToast({
title: "哎哟!刚刚走神了,请退出后重进",
icon: "none",
});
}); });
}, },
// 更改用户生日 // 更改用户生日
...@@ -61,8 +76,8 @@ export default { ...@@ -61,8 +76,8 @@ export default {
return res; return res;
}) })
.catch((err) => { .catch((err) => {
context.showToast({ title: err.data.msg, icon: 'none' }); context.showToast({ title: err.data.msg, icon: "none" });
return err return err;
}); });
}, },
// 更改用户昵称、性别 // 更改用户昵称、性别
...@@ -73,7 +88,10 @@ export default { ...@@ -73,7 +88,10 @@ export default {
return res; return res;
}) })
.catch((err) => { .catch((err) => {
context.showToast({ title: '服务器错误', icon: 'none' }); context.showToast({
title: "哎哟!刚刚走神了,请退出后重进",
icon: "none",
});
}); });
}, },
// 更改用户头像 // 更改用户头像
...@@ -84,9 +102,10 @@ export default { ...@@ -84,9 +102,10 @@ export default {
return res; return res;
}) })
.catch((err) => { .catch((err) => {
context.showToast({ title: '服务器错误', icon: 'none' }); context.showToast({
title: "哎哟!刚刚走神了,请退出后重进",
icon: "none",
});
}); });
}, },
}; };
export default { export default {
getMyOrder() { getMyOrder() {
return uni.$u.http return uni.$u.http
.get('/app/getMyOrder', { .get("/app/getMyOrder", {
params: {}, params: {},
custom: {noLoading: true}, custom: { noLoading: true },
}) })
.then((res) => res) .then((res) => res)
.catch((err) => { .catch((err) => {
// uni.showToast({ title: '服务器错误', icon: 'none' }) // uni.showToast({ title: '哎哟!刚刚走神了,请退出后重进', icon: 'none' })
console.log('服务器错误'); console.log("哎哟!刚刚走神了,请退出后重进");
}); });
}, },
orderRefund(data) { orderRefund(data) {
return uni.$u.http return uni.$u.http
.post('/system/refund', data) .post("/system/refund", data)
.then((res) => res) .then((res) => res)
.catch((err) => { .catch((err) => {
// uni.showToast({ title: '服务器错误', icon: 'none' }) // uni.showToast({ title: '哎哟!刚刚走神了,请退出后重进', icon: 'none' })
console.log('服务器错误'); console.log("哎哟!刚刚走神了,请退出后重进");
}); });
}, },
getShop(params) { getShop(params) {
return uni.$u.http return uni.$u.http
.get('/weixin/getArea', { .get("/weixin/getArea", {
params, params,
}) })
.then((res) => res) .then((res) => res)
.catch((err) => { .catch((err) => {
// uni.showToast({ title: '服务器错误', icon: 'none' }) // uni.showToast({ title: '哎哟!刚刚走神了,请退出后重进', icon: 'none' })
console.log('服务器错误'); console.log("哎哟!刚刚走神了,请退出后重进");
}); });
}, },
// 校验sku是否可用 // 校验sku是否可用
chekSku(params) { chekSku(params) {
return uni.$u.http return uni.$u.http
.get('/application/checkSku', { .get("/application/checkSku", {
params, params,
}) })
.then((res) => res) .then((res) => res)
.catch((err) => { .catch((err) => {
// uni.showToast({ title: '服务器错误', icon: 'none' }) // uni.showToast({ title: '哎哟!刚刚走神了,请退出后重进', icon: 'none' })
console.log('服务器错误'); console.log("哎哟!刚刚走神了,请退出后重进");
}); });
}, },
cancelOrder(params) { cancelOrder(params) {
return uni.$u.http return uni.$u.http
.get('order/cancel', { .get("order/cancel", {
params, params,
}) })
.then((res) => res) .then((res) => res)
.catch((err) => { .catch((err) => {
// uni.showToast({ title: '服务器错误', icon: 'none' }) // uni.showToast({ title: '哎哟!刚刚走神了,请退出后重进', icon: 'none' })
console.log('服务器错误'); console.log("哎哟!刚刚走神了,请退出后重进");
}); });
}, },
// 立即支付 // 立即支付
payOrder(params) { payOrder(params) {
console.log(params,'params') console.log(params, "params");
return uni.$u.http return uni.$u.http
.get('order/payOrder', { .get("order/payOrder", {
params, params,
}) })
.then((res) => res) .then((res) => res)
.catch((err) => { .catch((err) => {
// uni.showToast({ title: '服务器错误', icon: 'none' }) // uni.showToast({ title: '哎哟!刚刚走神了,请退出后重进', icon: 'none' })
console.log('服务器错误'); console.log("哎哟!刚刚走神了,请退出后重进");
}); });
}, },
getHomeOrder(params) { getHomeOrder(params) {
return uni.$u.http return uni.$u.http
.get(`/app/getHomeOrder?shopId=${params.shopId}`, { .get(`/app/getHomeOrder?shopId=${params.shopId}`, {
params: {}, params: {},
custom: {noLoading: true}, custom: { noLoading: true },
}) })
.then((res) => res) .then((res) => res)
.catch((err) => { .catch((err) => {
// uni.showToast({ title: '服务器错误', icon: 'none' }) // uni.showToast({ title: '哎哟!刚刚走神了,请退出后重进', icon: 'none' })
console.log('服务器错误'); console.log("哎哟!刚刚走神了,请退出后重进");
}); });
}, },
getWaitTine(data) { getWaitTine(data) {
return uni.$u.http return uni.$u.http
.post('app/getWaitTine', data) .post("app/getWaitTine", data)
.then((res) => res) .then((res) => res)
.catch((err) => { .catch((err) => {
// uni.showToast({ title: '服务器错误', icon: 'none' }) // uni.showToast({ title: '哎哟!刚刚走神了,请退出后重进', icon: 'none' })
console.log('服务器错误'); console.log("哎哟!刚刚走神了,请退出后重进");
}); });
}, },
moreOrder(params) { moreOrder(params) {
return uni.$u.http return uni.$u.http
.get('/app/getNextOrder', { .get("/app/getNextOrder", {
params, params,
}) })
.then((res) => res) .then((res) => res)
.catch((err) => { .catch((err) => {
// uni.showToast({ title: '服务器错误', icon: 'none' }) // uni.showToast({ title: '哎哟!刚刚走神了,请退出后重进', icon: 'none' })
console.log('服务器错误'); console.log("哎哟!刚刚走神了,请退出后重进");
}); });
}, },
checkSku(params) { checkSku(params) {
const shopInfo = JSON.parse(uni.getStorageSync('shopInfo')) const shopInfo = JSON.parse(uni.getStorageSync("shopInfo"));
return uni.$u.http return uni.$u.http
.get(`/application/checkSku?shopId=${shopInfo.id}&skuId=${params.skuId}`) .get(`/application/checkSku?shopId=${shopInfo.id}&skuId=${params.skuId}`)
.then((res) => res) .then((res) => res)
.catch((err) => { .catch((err) => {
// uni.showToast({ title: '服务器错误', icon: 'none' }) // uni.showToast({ title: '哎哟!刚刚走神了,请退出后重进', icon: 'none' })
console.log('服务器错误'); console.log("哎哟!刚刚走神了,请退出后重进");
}); });
}, },
getOrderDetail(params) { getOrderDetail(params) {
...@@ -114,8 +114,8 @@ export default { ...@@ -114,8 +114,8 @@ export default {
.get(`/order/${params.orderId}`) .get(`/order/${params.orderId}`)
.then((res) => res) .then((res) => res)
.catch((err) => { .catch((err) => {
// uni.showToast({ title: '服务器错误', icon: 'none' }) // uni.showToast({ title: '哎哟!刚刚走神了,请退出后重进', icon: 'none' })
console.log('服务器错误'); console.log("哎哟!刚刚走神了,请退出后重进");
}); });
}, },
getOrderWaiteTime(params) { getOrderWaiteTime(params) {
...@@ -123,8 +123,8 @@ export default { ...@@ -123,8 +123,8 @@ export default {
.get(`/app/getWaitTineByOrderId?orderId=${params.orderId}`) .get(`/app/getWaitTineByOrderId?orderId=${params.orderId}`)
.then((res) => res) .then((res) => res)
.catch((err) => { .catch((err) => {
// uni.showToast({ title: '服务器错误', icon: 'none' }) // uni.showToast({ title: '哎哟!刚刚走神了,请退出后重进', icon: 'none' })
console.log('服务器错误'); console.log("哎哟!刚刚走神了,请退出后重进");
}); });
}, },
// 获取退款详情 // 获取退款详情
...@@ -133,8 +133,8 @@ export default { ...@@ -133,8 +133,8 @@ export default {
.get(`/system/refund/list/${params}`) .get(`/system/refund/list/${params}`)
.then((res) => res) .then((res) => res)
.catch((err) => { .catch((err) => {
// uni.showToast({ title: '服务器错误', icon: 'none' }) // uni.showToast({ title: '哎哟!刚刚走神了,请退出后重进', icon: 'none' })
console.log('服务器错误'); console.log("哎哟!刚刚走神了,请退出后重进");
}); });
} },
}; };
import Config from '../static/config/index.js'; import Config from "../static/config/index.js";
import WXBizDataCrypt from './WXBizDataCrypt.js'; import WXBizDataCrypt from "./WXBizDataCrypt.js";
import context from '../main.js' import context from "../main.js";
import { $EventBus } from './EventBus'; import { $EventBus } from "./EventBus";
export default { export default {
// 组装提交订单数据 // 组装提交订单数据
...@@ -19,7 +19,7 @@ export default { ...@@ -19,7 +19,7 @@ export default {
realAmount: item.sku.discount * item.num, //实付金额 realAmount: item.sku.discount * item.num, //实付金额
amount: item.sku.price * item.num, //总价格 amount: item.sku.price * item.num, //总价格
specRuleDetail: JSON.stringify(item.sku.rules), //规格选项详情 specRuleDetail: JSON.stringify(item.sku.rules), //规格选项详情
specRuleIds: item.sku.rules.map((item) => item.ruleId).join(','), //规格选项详情 specRuleIds: item.sku.rules.map((item) => item.ruleId).join(","), //规格选项详情
skuId: item.skuId, //"sku ID" skuId: item.skuId, //"sku ID"
goodsCategory: item.categoryId, //商品分类 goodsCategory: item.categoryId, //商品分类
}; };
...@@ -38,30 +38,32 @@ export default { ...@@ -38,30 +38,32 @@ export default {
return DAta; return DAta;
} else { } else {
context.showToast({ context.showToast({
title: '请选择商品', title: "请选择商品",
}); });
} }
}, },
// 加入购物车数据 // 加入购物车数据
async getallNum(Obj, unCheckCount) { async getallNum(Obj, unCheckCount) {
console.log(Obj); console.log(Obj);
let shopCarInfo = uni.getStorageSync('shopCarInfo') || []; let shopCarInfo = uni.getStorageSync("shopCarInfo") || [];
let size = 0; let size = 0;
shopCarInfo.forEach((item) => (size += item.num)); shopCarInfo.forEach((item) => (size += item.num));
if(!unCheckCount) { if (!unCheckCount) {
let countOfOrder = uni.getStorageSync('countOfOrder') || 9; let countOfOrder = uni.getStorageSync("countOfOrder") || 9;
if (size >= countOfOrder) { if (size >= countOfOrder) {
context.showToast({ context.showToast({
title: '最多可一次购买'+countOfOrder+'杯', title: "一次最多可购买" + countOfOrder + "杯",
icon: 'none', icon: "none",
}); });
return false; return false;
} }
} }
if (shopCarInfo) { if (shopCarInfo) {
let currentGoods = shopCarInfo.find((v) => v.goodsId == Obj.goodsId && v.skuId == Obj.skuId); let currentGoods = shopCarInfo.find(
(v) => v.goodsId == Obj.goodsId && v.skuId == Obj.skuId
);
if (currentGoods) { if (currentGoods) {
currentGoods.num += Obj.num; currentGoods.num += Obj.num;
} else { } else {
...@@ -71,8 +73,8 @@ export default { ...@@ -71,8 +73,8 @@ export default {
shopCarInfo = [Obj]; shopCarInfo = [Obj];
} }
console.log(Obj); console.log(Obj);
uni.setStorageSync('shopCarInfo', shopCarInfo); uni.setStorageSync("shopCarInfo", shopCarInfo);
$EventBus.$emit('updateCar'); $EventBus.$emit("updateCar");
// if (callback) { // if (callback) {
// callback(); // callback();
// } // }
...@@ -82,11 +84,11 @@ export default { ...@@ -82,11 +84,11 @@ export default {
let goodsList = []; let goodsList = [];
let size = 0; let size = 0;
goodsList.forEach((item) => (size += item.num)); goodsList.forEach((item) => (size += item.num));
let countOfOrder = uni.getStorageSync('countOfOrder'); let countOfOrder = uni.getStorageSync("countOfOrder");
if (size >= countOfOrder) { if (size >= countOfOrder) {
context.showToast({ context.showToast({
title: '最多可一次购买'+countOfOrder+'杯', title: "一次最多可购买" + countOfOrder + "杯",
icon: 'none', icon: "none",
}); });
return false; return false;
} }
...@@ -102,7 +104,7 @@ export default { ...@@ -102,7 +104,7 @@ export default {
} else { } else {
goodsList = [Obj]; goodsList = [Obj];
} }
uni.setStorageSync('goodsList', goodsList); uni.setStorageSync("goodsList", goodsList);
}, },
// 解密手机 // 解密手机
...@@ -123,16 +125,16 @@ export default { ...@@ -123,16 +125,16 @@ export default {
}); });
} else { } else {
context.showToast({ context.showToast({
title: '二维码错误', title: "二维码错误",
icon: 'none', icon: "none",
}); });
} }
} }
}, },
fail() { fail() {
context.showToast({ context.showToast({
icon: 'none', icon: "none",
title: '扫码失败', title: "扫码失败",
}); });
}, },
}); });
...@@ -141,40 +143,57 @@ export default { ...@@ -141,40 +143,57 @@ export default {
var date = new Date(); var date = new Date();
date.setTime(value); date.setTime(value);
var month = date.getMonth() + 1; var month = date.getMonth() + 1;
if (month < 10) month = '0' + month; if (month < 10) month = "0" + month;
var cdate = date.getDate(); var cdate = date.getDate();
if (cdate < 10) cdate = '0' + cdate; if (cdate < 10) cdate = "0" + cdate;
var hours = date.getHours(); var hours = date.getHours();
if (hours < 10) hours = '0' + hours; if (hours < 10) hours = "0" + hours;
var minutes = date.getMinutes(); var minutes = date.getMinutes();
if (minutes < 10) minutes = '0' + minutes; if (minutes < 10) minutes = "0" + minutes;
var time = date.getFullYear() + '-' + month + '-' + cdate + ' ' + hours + ':' + minutes; var time =
date.getFullYear() +
"-" +
month +
"-" +
cdate +
" " +
hours +
":" +
minutes;
return time; return time;
}, },
numberFixed(data, fixed = 2) { numberFixed(data, fixed = 2) {
if (data == undefined) { if (data == undefined) {
return undefined; return undefined;
} else if (data == 0) { } else if (data == 0) {
return '0'; return "0";
} else { } else {
return (Math.round(Number(data) * Math.pow(10, fixed)) / Math.pow(10, fixed)).toFixed(fixed); return (
Math.round(Number(data) * Math.pow(10, fixed)) / Math.pow(10, fixed)
).toFixed(fixed);
} }
}, },
isInteger(value) { isInteger(value) {
return parseFloat(Number(value).toFixed(2)) return parseFloat(Number(value).toFixed(2));
}, },
// 计算经纬度之间的距离 // 计算经纬度之间的距离
// 根据经纬度计算距离,参数分别为第一点的纬度,经度;第二点的纬度,经度 // 根据经纬度计算距离,参数分别为第一点的纬度,经度;第二点的纬度,经度
getDistances(lat1, lng1, lat2, lng2) { getDistances(lat1, lng1, lat2, lng2) {
function rad(d) { function rad(d) {
return d * Math.PI / 180.0; return (d * Math.PI) / 180.0;
} }
var radLat1 = rad(lat1); var radLat1 = rad(lat1);
var radLat2 = rad(lat2); var radLat2 = rad(lat2);
var a = radLat1 - radLat2; var a = radLat1 - radLat2;
var b = rad(lng1) - rad(lng2); var b = rad(lng1) - rad(lng2);
var s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) + var s =
Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2))); 2 *
Math.asin(
Math.sqrt(
Math.pow(Math.sin(a / 2), 2) +
Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2)
)
);
s = s * 6378.137; // EARTH_RADIUS; s = s * 6378.137; // EARTH_RADIUS;
// 输出为公里 // 输出为公里
s = Math.round(s * 10000) / 10000; s = Math.round(s * 10000) / 10000;
...@@ -199,9 +218,9 @@ export default { ...@@ -199,9 +218,9 @@ export default {
//小小修改,这里返回对象 //小小修改,这里返回对象
let objData = { let objData = {
distance: distance, distance: distance,
distance_str: distance_str distance_str: distance_str,
} };
return objData return objData;
}, },
// 单位转换 // 单位转换
getPx(rpx) { getPx(rpx) {
...@@ -212,22 +231,22 @@ export default { ...@@ -212,22 +231,22 @@ export default {
// 返回上一页 // 返回上一页
goBack() { goBack() {
wx.navigateBack({ wx.navigateBack({
delta: 1 delta: 1,
}); });
}, },
// 解析url参数 // 解析url参数
getUrlParams2(url) { getUrlParams2(url) {
// 通过 ? 分割获取后面的参数字符串 // 通过 ? 分割获取后面的参数字符串
let urlStr = url.split('?')[1] let urlStr = url.split("?")[1];
// 创建空对象存储参数 // 创建空对象存储参数
let obj = {}; let obj = {};
// 再通过 & 将每一个参数单独分割出来 // 再通过 & 将每一个参数单独分割出来
let paramsArr = urlStr.split('&') let paramsArr = urlStr.split("&");
for(let i = 0,len = paramsArr.length;i < len;i++){ for (let i = 0, len = paramsArr.length; i < len; i++) {
// 再通过 = 将每一个参数分割为 key:value 的形式 // 再通过 = 将每一个参数分割为 key:value 的形式
let arr = paramsArr[i].split('=') let arr = paramsArr[i].split("=");
obj[arr[0]] = arr[1]; obj[arr[0]] = arr[1];
} }
return obj return obj;
} },
}; };
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment