cmy 3 years ago
parent
commit
bd7a98645a

+ 2 - 0
.gitignore

@@ -0,0 +1,2 @@
+/unpackage/dist
+.hbuilderx

+ 19 - 1
api/set.js

@@ -43,4 +43,22 @@ export function applelogin(data) {
 		data
 	});
 }
-// #endif
+// #endif
+
+
+//获取省市区
+export function getAddressArea(data) {
+	return request({
+		url: '/api/area',
+		method: 'get',
+		data
+	});
+}
+//获取村镇
+export function getAddressCity(data,id) {
+	return request({
+		url: '/api/village/'+id,
+		method: 'get',
+		data
+	});
+}

+ 0 - 18
config/app.js

@@ -1,18 +0,0 @@
-module.exports = {
-	// 请求域名 格式: https://您的域名
-	
-	HTTP_REQUEST_URL:'http://base.liuniu946.com',
-
-	
-	
-	// #ifdef H5
-	// HTTP_REQUEST_URL: window.location.protocol+"//"+window.location.host,
-	// #endif
-	HEADER:{
-		'content-type': 'application/json'
-	},
-	// 回话密钥名称 请勿修改此配置
-	TOKENNAME: 'Authori-zation',
-	// 缓存时间 0 永久
-	EXPIRE:0,
-};

+ 0 - 32
config/cache.js

@@ -1,32 +0,0 @@
-module.exports = {
-	//token
-	LOGIN_STATUS: 'LOGIN_STATUS_TOKEN',
-	// uid
-	UID:'UID',
-	//�û�
-	USER_INFO: 'USER_INFO',
-	//token�����¼�
-	EXPIRES_TIME: 'EXPIRES_TIME',
-	//�Ƿ���Ȩ
-	WX_AUTH: 'WX_AUTH',
-	//���ں���Ȩcode
-	STATE_KEY: 'wx_authorize_state',
-	//�û�����
-	LOGINTYPE: 'loginType',
-	//���ں���ת����
-	BACK_URL: 'login_back_url',
-	// ����code
-	STATE_R_KEY: 'roution_authorize_state',
-	//��ȨlogoС����
-	LOGO_URL: 'LOGO_URL',
-	//模板缓存
-	SUBSCRIBE_MESSAGE: 'SUBSCRIBE_MESSAGE',
-
-	TIPS_KEY: 'TIPS_KEY',
-
-	SPREAD: 'spread',
-	//缓存经度
-	CACHE_LONGITUDE: 'LONGITUDE',
-	//缓存纬度
-	CACHE_LATITUDE: 'LATITUDE',
-}

+ 1 - 1
manifest.json

@@ -73,7 +73,7 @@
         "devServer" : {
             "proxy" : {
                 "/api" : {
-                    "target" : "http://192.168.0.101/api",
+                    "target" : "http://xw.frp.liuniu946.com/api",
                     // "changeOrigin": true,
                     "pathRewrite" : {
                         "/api" : "" // rewrite path

+ 0 - 64
pages.json

@@ -3,40 +3,7 @@
 			"path": "pages/index/index",
 			"style": {
 				"enablePullDownRefresh": true,
-				// #ifdef MP
 				"navigationStyle": "custom",
-				// #endif
-				// #ifndef MP
-				"app-plus": {
-					"titleNView": {
-						"type": "transparent",
-						"searchInput": {
-							"backgroundColor": "rgba(231, 231, 231,.7)",
-							"borderRadius": "16px",
-							"placeholder": "请输入关键字",
-							"disabled": true,
-							"placeholderColor": "#606266",
-							"align": "left"
-						},
-						"buttons": [{
-								"fontSrc": "/static/yticon.ttf",
-								"text": "\ue60d",
-								"fontSize": "26",
-								"color": "#303133",
-								"float": "left",
-								"background": "rgba(0,0,0,0)"
-							},
-							{
-								"fontSrc": "/static/yticon.ttf",
-								"text": "\ue744",
-								"fontSize": "27",
-								"color": "#303133",
-								"background": "rgba(0,0,0,0)"
-							}
-						]
-					}
-				},
-				// #endif
 				"navigationBarTitleText": "商城首页"
 			}
 		},
@@ -464,37 +431,6 @@
 			}
 		}
 	],
-	"subPackages": [
-		{
-			"root": "pages/activity",
-			"name": "activity",
-			"pages":[{
-					"path": "goods_bargain/index",
-					"style": {
-						"navigationStyle": "custom"
-						// #ifdef MP
-						,"navigationBarTextStyle": "#fff"
-						// #endif
-					}
-				},
-				{
-					"path": "goods_bargain_details/index",
-					"style": {
-						"navigationStyle": "custom"
-						// #ifdef MP
-						,"navigationBarTextStyle": "#fff"
-						// #endif
-					}
-				},
-				{
-					"path": "bargain/index",
-					"style": {
-						"navigationBarTitleText": "砍价记录"
-					}
-				}
-			]
-		}
-	],
 	"globalStyle": {
 		"navigationBarTextStyle": "black",
 		"navigationBarTitleText": "uni-app",

+ 0 - 267
pages/activity/bargain/index.vue

@@ -1,267 +0,0 @@
-<template>
-	<view>
-		<block v-if="bargain.length>0">
-			<div class="bargain-record" ref="container">
-				<div class="item" v-for="(item, index) in bargain" :key="index">
-					<div class="picTxt acea-row row-between-wrapper">
-						<div class="pictrue">
-							<image :src="item.image" />
-						</div>
-						<div class="text acea-row row-column-around">
-							<div class="line1" style="width: 100%;">{{ item.title }}</div>
-							<count-down :justify-left="'justify-content:left'" :is-day="true" :tip-text="'倒计时 '" :day-text="' 天 '" :hour-text="' 时 '" :minute-text="' 分 '"
-							 :second-text="' 秒'" :datatime="item.datatime" v-if="item.status === 1"></count-down>
-							<div class="successTxt font-color-red" v-else-if="item.status === 3">砍价成功</div>
-							<div class="endTxt" v-else>活动已结束</div>
-							<div class="money font-color-red">
-								已砍至<span class="symbol">¥</span><span class="num">{{ item.residue_price }}</span>
-							</div>
-						</div>
-					</div>
-					<div class="bottom acea-row row-between-wrapper">
-						<div class="purple" v-if="item.status === 1">活动进行中</div>
-						<div class="success" v-else-if="item.status === 3">砍价成功</div>
-						<div class="end" v-else>活动已结束</div>
-						<div class="acea-row row-middle row-right">
-							<div class="bnt cancel" v-if="item.status === 1" @click="getBargainUserCancel(item.bargain_id)">
-								取消活动
-							</div>
-							<div class="bnt bg-color-red" v-if="item.status === 1" @click="goDetail(item.bargain_id)">
-								继续砍价
-							</div>
-							<!-- <div class="bnt bg-color-red" v-else @click="goList">重开一个</div> -->
-						</div>
-					</div>
-				</div>
-				<Loading :loaded="status" :loading="loadingList"></Loading>
-			</div>
-		</block>
-		<block v-if="bargain.length == 0">
-			<emptyPage title="暂无砍价记录~"></emptyPage>
-		</block>
-	</view>
-</template>
-<script>
-	import CountDown from "@/components/countDown";
-	import emptyPage from '@/components/emptyPage.vue'
-	import {
-		getBargainUserList,
-		getBargainUserCancel
-	} from "@/api/activity";
-	import {
-		userinfos
-	} from '@/api/user.js';
-	import Loading from "@/components/Loading";
-
-	export default {
-		name: "BargainRecord",
-		components: {
-			CountDown,
-			Loading,
-			emptyPage
-		},
-		props: {},
-		data: function() {
-			return {
-				bargain: [],
-				status: false, //砍价列表是否获取完成 false 未完成 true 完成
-				loadingList: false, //当前接口是否请求完成 false 完成 true 未完成
-				page: 1, //页码
-				limit: 20, //数量
-				userInfo: {}
-			};
-		},
-		onLoad: function() {
-			this.getBargainUserList();
-			this.getUserInfo();
-			// this.$scroll(this.$refs.container, () => {
-			//   !this.loadingList && this.getBargainUserList();
-			// });
-		},
-		methods: {
-			goDetail: function(id) {
-				// this.$router.push({
-				// 	path: "/activity/dargain_detail/" + id +'&bargain='+ userInfo.uid
-				// });
-				uni.navigateTo({
-					url: `/pages/activity/goods_bargain_details/index?id=${id}&bargain=${this.userInfo.uid}`
-				})
-			},
-			// 砍价列表
-			goList: function() {
-				uni.navigateTo({
-					url: '/pages/activity/goods_bargain/index'
-				})
-			},
-			getBargainUserList: function() {
-				var that = this;
-				if (that.loadingList) return;
-				if (that.status) return;
-				getBargainUserList({
-						page: that.page,
-						limit: that.limit
-					})
-					.then(res => {
-						that.status = res.data.length < that.limit;
-						that.bargain.push.apply(that.bargain, res.data);
-						that.page++;
-						that.loadingList = false;
-					})
-					.catch(res => {
-						that.$dialog.error(res.msg);
-					});
-			},
-			getBargainUserCancel: function(bargainId) {
-				var that = this;
-				uni.showModal({
-				    title: '提示',
-				    content: '确定取消砍价商品吗',
-				    success: function (res) {
-				        if (res.confirm) {
-				            console.log('用户点击确定');
-							getBargainUserCancel({
-									bargainId: bargainId
-								})
-								.then(res => {
-									that.status = false;
-									that.loadingList = false;
-									that.page = 1;
-									that.bargain = [];
-									that.getBargainUserList();
-									uni.showToast({
-										title:res.msg
-									});
-								})
-								.catch(res => {
-									uni.showToast({
-										title:res
-									});
-								});
-				        } else if (res.cancel) {
-				            console.log('用户点击取消');
-				        }
-				    }
-				});
-			},
-			/**
-			 * 获取个人用户信息
-			 */
-			getUserInfo: function() {
-				let that = this;
-				userinfos().then(res => {
-					that.userInfo = res.data;
-				});
-			},
-		},
-		onReachBottom() {
-			this.getBargainUserList();
-		}
-	};
-</script>
-
-<style lang="scss">
-	page{
-		background-color: #f5f5f5;
-	}
-	/*砍价记录*/
-	.bargain-record .item .picTxt .text .time .styleAll {
-		color: #fc4141;
-		font-size:24rpx;
-	}
-	.bargain-record .item .picTxt .text .time .red {
-		color: #999;
-		font-size:24rpx;
-	}
-	.bargain-record .item {
-		background-color: #fff;
-		margin-bottom: 12upx;
-	}
-
-	.bargain-record .item .picTxt {
-		height: 210upx;
-		border-bottom: 1px solid #f0f0f0;
-		padding: 0 30upx;
-	}
-
-	.bargain-record .item .picTxt .pictrue {
-		width: 150upx;
-		height: 150upx;
-	}
-
-	.bargain-record .item .picTxt .pictrue image {
-		width: 100%;
-		height: 100%;
-		border-radius: 6upx;
-	}
-
-	.bargain-record .item .picTxt .text {
-		width: 515upx;
-		font-size: 30upx;
-		color: #282828;
-		height: 150upx;
-	}
-
-	.bargain-record .item .picTxt .text .time {
-		font-size: 24upx;
-		color: #868686;
-		justify-content: left !important;
-	}
-	
-	.bargain-record .item .picTxt .text .successTxt{
-		font-size:24rpx;
-	}
-	
-	.bargain-record .item .picTxt .text .endTxt{
-		font-size:24rpx;
-		color: #999;
-	}
-	.bargain-record .item .picTxt .text .money {
-		font-size: 24upx;
-	}
-
-	.bargain-record .item .picTxt .text .money .num {
-		font-size: 32upx;
-		font-weight: bold;
-	}
-
-	.bargain-record .item .picTxt .text .money .symbol {
-		font-weight: bold;
-	}
-
-	.bargain-record .item .bottom {
-		height: 100upx;
-		padding: 0 30upx;
-		font-size: 27upx;
-	}
-
-	.bargain-record .item .bottom .purple {
-		color: #f78513;
-	}
-
-	.bargain-record .item .bottom .end {
-		color: #999;
-	}
-
-	.bargain-record .item .bottom .success {
-		color: #e93323;
-	}
-
-	.bargain-record .item .bottom .bnt {
-		font-size: 27upx;
-		color: #fff;
-		width: 176upx;
-		height: 60upx;
-		border-radius: 32upx;
-		text-align: center;
-		line-height: 60upx;
-	}
-
-	.bargain-record .item .bottom .bnt.cancel {
-		color: #aaa;
-		border: 1px solid #ddd;
-	}
-
-	.bargain-record .item .bottom .bnt~.bnt {
-		margin-left: 18upx;
-	}
-</style>

File diff suppressed because it is too large
+ 0 - 172
pages/activity/goods_bargain/index.vue


File diff suppressed because it is too large
+ 0 - 726
pages/activity/goods_bargain_details/index.vue


+ 120 - 19
pages/set/addressManage.vue

@@ -9,15 +9,23 @@
 			<input class="input" type="number" v-model="addressData.mobile" placeholder="收货人手机号码" placeholder-class="placeholder" />
 		</view>
 		<view class="row b-b">
-			<text class="tit">地址</text>
-			<pickerAddress class="input" @change="onCityClick">{{addressDetail||'请选择地址'}}</pickerAddress>
-			<text class="iconfont iconlocation"></text>
+			<text class="tit">省市区</text>
+			<picker mode="multiSelector" :range="areaJs" range-key="name" :value="addressIndex" @columnchange="onCityClick" @change="changeArea">
+				<view v-if="addressDetail">{{ addressDetail }}</view>
+				<view v-else class="font-color-gray">请选择省市区</view>
+			</picker>
+		</view>
+		<view class="row b-b">
+			<text class="tit">村镇</text>
+			<picker mode="multiSelector" :range="cityJs" range-key="name" :value="addressIndexCity" @columnchange="onCityChange" @change="changeCity">
+				<view v-if="addressDetailCity">{{ addressDetailCity }}</view>
+				<view v-else class="font-color-gray">请选择村镇</view>
+			</picker>
 		</view>
 		<view class="row b-b">
 			<text class="tit">门牌号</text>
 			<input class="input" type="text" v-model="addressData.area" placeholder="楼号、门牌" placeholder-class="placeholder" />
 		</view>
-
 		<uni-list class="margin-t-20">
 			<uni-list-item
 				title="设为默认"
@@ -37,18 +45,21 @@
 import uniList from '@/components/uni-list/uni-list.vue';
 import uniListItem from '@/components/uni-list-item/uni-list-item.vue';
 import uniPopup from '@/components/uni-popup/uni-popup.vue';
-import  pickerAddress from '@/components/wangding-pickerAddress/wangding-pickerAddress.vue';
 import { addressEdit } from '@/api/user.js';
+import { getAddressArea, getAddressCity } from '@/api/set.js';
+import { mapState, mapMutations } from 'vuex';
 export default {
 	components: {
 		uniList,
 		uniListItem,
-		pickerAddress,
 		uniPopup
 	},
 	data() {
 		return {
-			addressDetail: '',
+			addressIndex: [0, 0, 0], //当前选中的省市区
+			addressIndexCity: [0, 0], //当前选中的村镇
+			addressDetail: '', //省市区名称
+			addressDetailCity: '', //村镇名称
 			addressData: {
 				name: '',
 				mobile: '',
@@ -62,13 +73,29 @@ export default {
 			}
 		};
 	},
+	computed: {
+		...mapState('address', ['area', 'city']),
+		// 省市区动态渲染列表
+		areaJs() {
+			if (this.area.length > 0) {
+				const index1 = this.addressIndex[0];
+				return [this.area, this.area[index1].child, this.area[index1].child[this.addressIndex[1]].child];
+			}
+		},
+		// 村镇切换渲染
+		cityJs() {
+			if (this.city.length > 0) {
+				const index1 = this.addressIndexCity[0];
+				return [this.city, this.city[index1].child];
+			}
+		}
+	},
 	onLoad(option) {
 		let title = '新增收货地址';
 		if (option.type === 'edit') {
 			title = '编辑收货地址';
 			let data = JSON.parse(option.data);
 			console.log(data);
-
 			this.addressData = {
 				name: data.real_name,
 				mobile: data.phone,
@@ -87,15 +114,89 @@ export default {
 		uni.setNavigationBarTitle({
 			title
 		});
+		this.init();
 	},
 	methods: {
-		// 选中城市切换
-		onCityClick({data}) {
-			let address = this.addressData.address;
-			address.province = data[0];
-			address.city = data[1];
-			address.district = data[2];
-			this.addressDetail = data.join('');
+		...mapMutations('address', ['setArea', 'setCity']),
+		// 初始化
+		init() {
+			if (this.area.length <= 0) {
+				// 获取省市区信息
+				this.getAddressArea();
+			}
+		},
+		// 获取省市区信息
+		getAddressArea() {
+			getAddressArea().then(e => {
+				this.setArea(e.data);
+				this.getAddressCity(e.data[0].child[0].child[0].city_id);
+			});
+		},
+		// 获取村镇信息
+		getAddressCity(id) {
+			uni.showLoading({
+				title: '村镇数据加载中....',
+				mask: true
+			});
+			getAddressCity({}, id)
+				.then(e => {
+					uni.hideLoading();
+					this.setCity(e.data);
+				})
+				.catch(e => {
+					uni.hideLoading();
+					uni.showToast({
+						title: ''
+					});
+				});
+		},
+		//省市区确认后村镇数据更新
+		changeArea(e) {
+			if (this.area.length > 0) {
+				const index0 = this.addressIndex[0];
+				const index1 = this.addressIndex[1];
+				const index2 = this.addressIndex[2];
+				this.addressDetail = this.areaJs[0][index0].name + this.areaJs[1][index1].name + this.areaJs[2][index2].name;
+				this.getAddressCity(this.areaJs[2][index2].city_id);
+			} else {
+				this.addressDetail = '';
+			}
+		},
+		// 村镇切换
+		changeCity(e) {
+			if (this.area.length > 0) {
+				const index0 = this.addressIndexCity[0];
+				const index1 = this.addressIndexCity[1];
+				this.addressDetailCity = this.cityJs[0][index0].name + this.cityJs[1][index1].name;
+			} else {
+				this.addressDetailCity = '';
+			}
+		},
+		// 选中省市区切换
+		onCityClick(data) {
+			// 采用map防止直接修改无法触发数组set事件
+			this.addressIndex = this.addressIndex.map((e, ind) => {
+				if (data.detail.column < ind) {
+					e = 0;
+				}
+				if (ind == data.detail.column) {
+					e = data.detail.value;
+				}
+				return e;
+			});
+		},
+		// 选中村镇切换
+		onCityChange(data) {
+			// 采用map防止直接修改无法触发数组set事件
+			this.addressIndexCity = this.addressIndexCity.map((e, ind) => {
+				if (data.detail.column < ind) {
+					e = 0;
+				}
+				if (ind == data.detail.column) {
+					e = data.detail.value;
+				}
+				return e;
+			});
 		},
 		//地图选择地址
 		chooseLocation() {
@@ -143,13 +244,13 @@ export default {
 				},
 				detail: data.area,
 				is_default: data.default,
-				id: data.id||"",
-				type:1
+				id: data.id || '',
+				type: 1
 			}).then(function(e) {
 				obj.$api.prePage().refreshList();
 				uni.showToast({
-					title:'提交成功',
-					duration:2000
+					title: '提交成功',
+					duration: 2000
 				});
 				setTimeout(function() {
 					uni.navigateBack();

BIN
static/yticon.ttf


+ 4 - 2
store/index.js

@@ -1,12 +1,13 @@
 import Vue from 'vue'
 import Vuex from 'vuex'
 import user from './model/user'
+import address from './model/address'
 Vue.use(Vuex)
 
 const store = new Vuex.Store({
 	state: {
 		// baseURL:"http://yrh.liuniu946.com",//'http://eb.shuibo.net',//请求地址配置 
-		baseURL:'http://base.liuniu946.com',//请求地址配置 
+		baseURL:'http://xw.frp.liuniu946.com/',//请求地址配置 
 		urlFile:'/index',//项目部署所在文件夹
 		userInfo: {}, //登录信息
 		loginInterceptor:false,//是否打开强制登录
@@ -26,7 +27,8 @@ const store = new Vuex.Store({
 		}
 	},
 	modules:{
-		user
+		user,
+		address
 	},
 	actions: {}
 })

+ 25 - 0
store/model/address.js

@@ -0,0 +1,25 @@
+let state = {
+	area:[],//省市区数据
+	city:[]//村镇数据
+}
+
+let mutations = {
+	// 设置省市区
+	setArea(state,data){
+		state.area = data;
+	},
+	// 设置村镇
+	setCity(state,data){
+		state.city = data;
+	}
+	
+	
+}
+let getters = {}
+
+export default {
+	namespaced: true,
+	state,
+	mutations,
+	getters
+}

+ 0 - 110
utils/SubscribeMessage.js

@@ -1,110 +0,0 @@
-import {
-	SUBSCRIBE_MESSAGE
-} from '../config/cache.js';
-
-export function auth() {
-	let tmplIds = {};
-	let messageTmplIds = uni.getStorageSync(SUBSCRIBE_MESSAGE);
-	tmplIds = messageTmplIds ? JSON.parse(messageTmplIds) : {};
-	return tmplIds;
-}
-
-/**
- * 支付成功后订阅消息id
- * 订阅  确认收货通知 订单支付成功  新订单管理员提醒 
- */
-export function openPaySubscribe() {
-	let tmplIds = auth();
-	return subscribe([
-		tmplIds.oreder_takever,
-		tmplIds.order_pay_success,
-		tmplIds.order_new,
-	]);
-}
-
-/**
- * 订单相关订阅消息
- * 送货 发货 取消订单
- */
-export function openOrderSubscribe() {
-	let tmplIds = auth();
-	return subscribe([
-		tmplIds.order_deliver_success,
-		tmplIds.order_postage_success,
-		tmplIds.order_clone
-	]);
-}
-
-/**
- * 提现消息订阅
- * 成功 和 失败 消息
- */
-export function openExtrctSubscribe() {
-	let tmplIds = auth();
-	return subscribe([
-		tmplIds.user_extract
-	]);
-}
-
-/**
- * 拼团成功
- */
-export function openPinkSubscribe() {
-	let tmplIds = auth();
-	return subscribe([
-		tmplIds.pink_true
-	]);
-}
-
-/**
- * 砍价成功
- */
-export function openBargainSubscribe() {
-	let tmplIds = auth();
-	return subscribe([
-		tmplIds.bargain_success
-	]);
-}
-
-/**
- * 订单退款
- */
-export function openOrderRefundSubscribe() {
-	let tmplIds = auth();
-	return subscribe([tmplIds.order_refund]);
-}
-
-/**
- * 充值成功
- */
-export function openRechargeSubscribe() {
-	let tmplIds = auth();
-	return subscribe([tmplIds.recharge_success]);
-}
-
-/**
- * 提现
- */
-export function openEextractSubscribe() {
-	let tmplIds = auth();
-	return subscribe([tmplIds.user_extract]);
-}
-
-/**
- * 调起订阅界面
- * array tmplIds 模板id
- */
-export function subscribe(tmplIds) {
-	 let wecaht = wx;
-	return new Promise((reslove, reject) => {
-		wecaht.requestSubscribeMessage({
-			tmplIds: tmplIds,
-			success(res) {
-				return reslove(res);
-			},
-			fail(res) {
-				return reslove(res);
-			}
-		})
-	});
-}

+ 1 - 1
utils/rocessor.js

@@ -117,4 +117,4 @@ export function getTime(time) {
 	const minu = date.getMinutes();
 	const sec = date.getSeconds();
 	return year + '-' + mon + '-' + day + ' ' + hours + ':' + minu + ':' + sec;
-}
+}

+ 0 - 550
utils/util.js

@@ -1,550 +0,0 @@
-import {
- 	TOKENNAME,
- 	HTTP_REQUEST_URL
- } from '../config/app.js';
- import store from '../store';
- import {
- 	pathToBase64
- } from '@/plugin/image-tools/index.js';
- // #ifdef APP-PLUS
- // import permision from "permission.js"
- // #endif
- export default {
- 	/**
- 	 * opt  object | string
- 	 * to_url object | string
- 	 * 例:
- 	 * this.Tips('/pages/test/test'); 跳转不提示
- 	 * this.Tips({title:'提示'},'/pages/test/test'); 提示并跳转
- 	 * this.Tips({title:'提示'},{tab:1,url:'/pages/index/index'}); 提示并跳转值table上
- 	 * tab=1 一定时间后跳转至 table上
- 	 * tab=2 一定时间后跳转至非 table上
- 	 * tab=3 一定时间后返回上页面
- 	 * tab=4 关闭所有页面跳转至非table上
- 	 * tab=5 关闭当前页面跳转至table上
- 	 */
- 	Tips: function(opt, to_url) {
- 		if (typeof opt == 'string') {
- 			to_url = opt;
- 			opt = {};
- 		}
- 		let title = opt.title || '',
- 			icon = opt.icon || 'none',
- 			endtime = opt.endtime || 2000,
- 			success = opt.success;
- 		if (title) uni.showToast({
- 			title: title,
- 			icon: icon,
- 			duration: endtime,
- 			success
- 		})
- 		if (to_url != undefined) {
- 			if (typeof to_url == 'object') {
- 				let tab = to_url.tab || 1,
- 					url = to_url.url || '';
- 				switch (tab) {
- 					case 1:
- 						//一定时间后跳转至 table
- 						setTimeout(function() {
- 							uni.switchTab({
- 								url: url
- 							})
- 						}, endtime);
- 						break;
- 					case 2:
- 						//跳转至非table页面
- 						setTimeout(function() {
- 							uni.navigateTo({
- 								url: url,
- 							})
- 						}, endtime);
- 						break;
- 					case 3:
- 						//返回上页面
- 						setTimeout(function() {
- 							// #ifndef H5
- 							uni.navigateBack({
- 								delta: parseInt(url),
- 							})
- 							// #endif
- 							// #ifdef H5
- 							history.back();
- 							// #endif
- 						}, endtime);
- 						break;
- 					case 4:
- 						//关闭当前所有页面跳转至非table页面
- 						setTimeout(function() {
- 							uni.reLaunch({
- 								url: url,
- 							})
- 						}, endtime);
- 						break;
- 					case 5:
- 						//关闭当前页面跳转至非table页面
- 						setTimeout(function() {
- 							uni.redirectTo({
- 								url: url,
- 							})
- 						}, endtime);
- 						break;
- 				}
-
- 			} else if (typeof to_url == 'function') {
- 				setTimeout(function() {
- 					to_url && to_url();
- 				}, endtime);
- 			} else {
- 				//没有提示时跳转不延迟
- 				setTimeout(function() {
- 					uni.navigateTo({
- 						url: to_url,
- 					})
- 				}, title ? endtime : 0);
- 			}
- 		}
- 	},
- 	/**
- 	 * 移除数组中的某个数组并组成新的数组返回
- 	 * @param array array 需要移除的数组
- 	 * @param int index 需要移除的数组的键值
- 	 * @param string | int 值
- 	 * @return array
- 	 * 
- 	 */
- 	ArrayRemove: function(array, index, value) {
- 		const valueArray = [];
- 		if (array instanceof Array) {
- 			for (let i = 0; i < array.length; i++) {
- 				if (typeof index == 'number' && array[index] != i) {
- 					valueArray.push(array[i]);
- 				} else if (typeof index == 'string' && array[i][index] != value) {
- 					valueArray.push(array[i]);
- 				}
- 			}
- 		}
- 		return valueArray;
- 	},
- 	/**
- 	 * 生成海报获取文字
- 	 * @param string text 为传入的文本
- 	 * @param int num 为单行显示的字节长度
- 	 * @return array 
- 	 */
- 	textByteLength: function(text, num) {
- 		let strLength = 0;
- 		let rows = 1;
- 		let str = 0;
- 		let arr = [];
- 		for (let j = 0; j < text.length; j++) {
- 			if (text.charCodeAt(j) > 255) {
- 				strLength += 2;
- 				if (strLength > rows * num) {
- 					strLength++;
- 					arr.push(text.slice(str, j));
- 					str = j;
- 					rows++;
- 				}
- 			} else {
- 				strLength++;
- 				if (strLength > rows * num) {
- 					arr.push(text.slice(str, j));
- 					str = j;
- 					rows++;
- 				}
- 			}
- 		}
- 		arr.push(text.slice(str, text.length));
- 		return [strLength, arr, rows] //  [处理文字的总字节长度,每行显示内容的数组,行数]
- 	},
-
- 	/**
- 	 * 获取分享海报
- 	 * @param array arr2 海报素材
- 	 * @param string store_name 素材文字
- 	 * @param string price 价格
- 	 * @param function successFn 回调函数
- 	 * 
- 	 * 
- 	 */
- 	PosterCanvas: function(arr2, store_name, price, successFn) {
- 		let that = this;
- 		uni.showLoading({
- 			title: '海报生成中',
- 			mask: true
- 		});
- 		const ctx = uni.createCanvasContext('myCanvas');
- 		ctx.clearRect(0, 0, 0, 0);
- 		/**
- 		 * 只能获取合法域名下的图片信息,本地调试无法获取
- 		 * 
- 		 */
- 		uni.getImageInfo({
- 			src: arr2[0],
- 			success: function(res) {
-				console.log(res,'getImageInfo')
- 				const WIDTH = res.width;
- 				const HEIGHT = res.height;
- 				ctx.drawImage(arr2[0], 0, 0, WIDTH, HEIGHT);
- 				ctx.drawImage(arr2[1], 0, 0, WIDTH, WIDTH);
- 				ctx.save();
- 				let r = 90;
- 				let d = r * 2;
- 				let cx = 40;
- 				let cy = 990;
- 				ctx.arc(cx + r, cy + r, r, 0, 2 * Math.PI);
- 				// ctx.clip();
- 				ctx.drawImage(arr2[2], cx, cy,d,d);
- 				ctx.restore();
- 				const CONTENT_ROW_LENGTH = 40;
- 				let [contentLeng, contentArray, contentRows] = that.textByteLength(store_name, CONTENT_ROW_LENGTH);
- 				if (contentRows > 2) {
- 					contentRows = 2;
- 					let textArray = contentArray.slice(0, 2);
- 					textArray[textArray.length - 1] += '……';
- 					contentArray = textArray;
- 				}
- 				ctx.setTextAlign('center');
- 				ctx.setFontSize(32);
- 				let contentHh = 32 * 1.3;
- 				for (let m = 0; m < contentArray.length; m++) {
- 					ctx.fillText(contentArray[m], WIDTH / 2, 820 + contentHh * m);
- 				}
- 				ctx.setTextAlign('center')
- 				ctx.setFontSize(48);
- 				ctx.setFillStyle('red');
- 				ctx.fillText('¥' + price, WIDTH / 2, 880 + contentHh);
- 				ctx.draw(true, function() {
- 					uni.canvasToTempFilePath({
- 						canvasId: 'myCanvas',
- 						fileType: 'png',
- 						destWidth: WIDTH,
- 						destHeight: HEIGHT,
- 						success: function(res) {
- 							uni.hideLoading();
- 							successFn && successFn(res.tempFilePath);
- 						}
- 					})
- 				});
- 			},
- 			fail: function(err) {
- 				uni.hideLoading();
- 				that.Tips({
- 					title: '无法获取图片信息'
- 				});
- 			}
- 		})
- 	},
- 	/*
- 	 * 单图上传
- 	 * @param object opt
- 	 * @param callable successCallback 成功执行方法 data 
- 	 * @param callable errorCallback 失败执行方法 
- 	 */
- 	uploadImageOne: function(opt, successCallback, errorCallback) {
- 		let that = this;
- 		if (typeof opt === 'string') {
- 			let url = opt;
- 			opt = {};
- 			opt.url = url;
- 		}
- 		let count = opt.count || 1,
- 			sizeType = opt.sizeType || ['compressed'],
- 			sourceType = opt.sourceType || ['album', 'camera'],
- 			is_load = opt.is_load || true,
- 			uploadUrl = opt.url || '',
- 			inputName = opt.name || 'pics';
- 		uni.chooseImage({
- 			count: count, //最多可以选择的图片总数  
- 			sizeType: sizeType, // 可以指定是原图还是压缩图,默认二者都有  
- 			sourceType: sourceType, // 可以指定来源是相册还是相机,默认二者都有  
- 			success: function(res) {
-				console.log()
- 				//启动上传等待中...  
- 				uni.showLoading({
- 					title: '图片上传中',
- 				});
-				uni.uploadFile({
-					url: HTTP_REQUEST_URL + '/api/' + uploadUrl,
-					filePath: res.tempFilePaths[0],
-					name: inputName,
-					formData: {
-						'filename': inputName
-					},
-					header: {
-						// #ifdef MP
-						"Content-Type": "multipart/form-data",
-						// #endif
-						[TOKENNAME]: 'Bearer ' + store.state.app.token
-					},
-					success: function(res) {
-						uni.hideLoading();
-						if (res.statusCode == 403) {
-							that.Tips({
-								title: res.data
-							});
-						} else {
-							let data = res.data ? JSON.parse(res.data) : {};
-							if (data.status == 200) {
-								successCallback && successCallback(data)
-							} else {
-								errorCallback && errorCallback(data);
-								that.Tips({
-									title: data.msg
-								});
-							}
-						}
-					},
-					fail: function(res) {
-						uni.hideLoading();
-						that.Tips({
-							title: '上传图片失败'
-						});
-					}
-				})
- 				// pathToBase64(res.tempFilePaths[0])
- 				// 	.then(imgBase64 => {
- 				// 		console.log(imgBase64);
- 						
- 				// 	})
- 				// 	.catch(error => {
- 				// 		console.error(error)
- 				// 	})
- 			}
- 		})
- 	},
- 	/**
- 	 * 处理服务器扫码带进来的参数
- 	 * @param string param 扫码携带参数
- 	 * @param string k 整体分割符 默认为:&
- 	 * @param string p 单个分隔符 默认为:=
- 	 * @return object
- 	 * 
- 	 */
- 	// #ifdef MP
- 	getUrlParams: function(param, k, p) {
- 		if (typeof param != 'string') return {};
- 		k = k ? k : '&'; //整体参数分隔符
- 		p = p ? p : '='; //单个参数分隔符
- 		var value = {};
- 		if (param.indexOf(k) !== -1) {
- 			param = param.split(k);
- 			for (var val in param) {
- 				if (param[val].indexOf(p) !== -1) {
- 					var item = param[val].split(p);
- 					value[item[0]] = item[1];
- 				}
- 			}
- 		} else if (param.indexOf(p) !== -1) {
- 			var item = param.split(p);
- 			value[item[0]] = item[1];
- 		} else {
- 			return param;
- 		}
- 		return value;
- 	},
- 	// #endif
- 	/*
- 	 * 合并数组
- 	 */
- 	SplitArray(list, sp) {
- 		if (typeof list != 'object') return [];
- 		if (sp === undefined) sp = [];
- 		for (var i = 0; i < list.length; i++) {
- 			sp.push(list[i]);
- 		}
- 		return sp;
- 	},
- 	trim(str) {
- 		return String.prototype.trim.call(str);
- 	},
- 	$h: {
- 		//除法函数,用来得到精确的除法结果
- 		//说明:javascript的除法结果会有误差,在两个浮点数相除的时候会比较明显。这个函数返回较为精确的除法结果。
- 		//调用:$h.Div(arg1,arg2)
- 		//返回值:arg1除以arg2的精确结果
- 		Div: function(arg1, arg2) {
- 			arg1 = parseFloat(arg1);
- 			arg2 = parseFloat(arg2);
- 			var t1 = 0,
- 				t2 = 0,
- 				r1, r2;
- 			try {
- 				t1 = arg1.toString().split(".")[1].length;
- 			} catch (e) {}
- 			try {
- 				t2 = arg2.toString().split(".")[1].length;
- 			} catch (e) {}
- 			r1 = Number(arg1.toString().replace(".", ""));
- 			r2 = Number(arg2.toString().replace(".", ""));
- 			return this.Mul(r1 / r2, Math.pow(10, t2 - t1));
- 		},
- 		//加法函数,用来得到精确的加法结果
- 		//说明:javascript的加法结果会有误差,在两个浮点数相加的时候会比较明显。这个函数返回较为精确的加法结果。
- 		//调用:$h.Add(arg1,arg2)
- 		//返回值:arg1加上arg2的精确结果
- 		Add: function(arg1, arg2) {
- 			arg2 = parseFloat(arg2);
- 			var r1, r2, m;
- 			try {
- 				r1 = arg1.toString().split(".")[1].length
- 			} catch (e) {
- 				r1 = 0
- 			}
- 			try {
- 				r2 = arg2.toString().split(".")[1].length
- 			} catch (e) {
- 				r2 = 0
- 			}
- 			m = Math.pow(100, Math.max(r1, r2));
- 			return (this.Mul(arg1, m) + this.Mul(arg2, m)) / m;
- 		},
- 		//减法函数,用来得到精确的减法结果
- 		//说明:javascript的加法结果会有误差,在两个浮点数相加的时候会比较明显。这个函数返回较为精确的减法结果。
- 		//调用:$h.Sub(arg1,arg2)
- 		//返回值:arg1减去arg2的精确结果
- 		Sub: function(arg1, arg2) {
- 			arg1 = parseFloat(arg1);
- 			arg2 = parseFloat(arg2);
- 			var r1, r2, m, n;
- 			try {
- 				r1 = arg1.toString().split(".")[1].length
- 			} catch (e) {
- 				r1 = 0
- 			}
- 			try {
- 				r2 = arg2.toString().split(".")[1].length
- 			} catch (e) {
- 				r2 = 0
- 			}
- 			m = Math.pow(10, Math.max(r1, r2));
- 			//动态控制精度长度
- 			n = (r1 >= r2) ? r1 : r2;
- 			return ((this.Mul(arg1, m) - this.Mul(arg2, m)) / m).toFixed(n);
- 		},
- 		//乘法函数,用来得到精确的乘法结果
- 		//说明:javascript的乘法结果会有误差,在两个浮点数相乘的时候会比较明显。这个函数返回较为精确的乘法结果。
- 		//调用:$h.Mul(arg1,arg2)
- 		//返回值:arg1乘以arg2的精确结果
- 		Mul: function(arg1, arg2) {
- 			arg1 = parseFloat(arg1);
- 			arg2 = parseFloat(arg2);
- 			var m = 0,
- 				s1 = arg1.toString(),
- 				s2 = arg2.toString();
- 			try {
- 				m += s1.split(".")[1].length
- 			} catch (e) {}
- 			try {
- 				m += s2.split(".")[1].length
- 			} catch (e) {}
- 			return Number(s1.replace(".", "")) * Number(s2.replace(".", "")) / Math.pow(10, m);
- 		},
- 	},
- 	// 获取地理位置;
- 	$L: {
- 		async getLocation() {
- 			// #ifdef APP-PLUS
- 			let status = await this.checkPermission();
- 			if (status !== 1) {
- 				return;
- 			}
- 			// #endif
- 			// #ifdef MP-WEIXIN || MP-TOUTIAO || MP-QQ
- 			let status = await this.getSetting();
- 			if (status === 2) {
- 				this.openSetting();
- 				return;
- 			}
- 			// #endif
-
- 			this.doGetLocation();
- 		},
- 		doGetLocation() {
- 			uni.getLocation({
- 				success: (res) => {
- 					uni.removeStorageSync('CACHE_LONGITUDE');
- 					uni.removeStorageSync('CACHE_LATITUDE');
- 					uni.setStorageSync('CACHE_LONGITUDE', res.longitude);
- 					uni.setStorageSync('CACHE_LATITUDE', res.latitude);
- 				},
- 				fail: (err) => {
- 					// #ifdef MP-BAIDU
- 					if (err.errCode === 202 || err.errCode === 10003) { // 202模拟器 10003真机 user deny
- 						this.openSetting();
- 					}
- 					// #endif
- 					// #ifndef MP-BAIDU
- 					if (err.errMsg.indexOf("auth deny") >= 0) {
- 						uni.showToast({
- 							title: "访问位置被拒绝"
- 						})
- 					} else {
- 						uni.showToast({
- 							title: err.errMsg
- 						})
- 					}
- 					// #endif
- 				}
- 			})
- 		},
- 		getSetting: function() {
- 			return new Promise((resolve, reject) => {
- 				uni.getSetting({
- 					success: (res) => {
- 						if (res.authSetting['scope.userLocation'] === undefined) {
- 							resolve(0);
- 							return;
- 						}
- 						if (res.authSetting['scope.userLocation']) {
- 							resolve(1);
- 						} else {
- 							resolve(2);
- 						}
- 					}
- 				});
- 			});
- 		},
- 		openSetting: function() {
- 			uni.openSetting({
- 				success: (res) => {
- 					if (res.authSetting && res.authSetting['scope.userLocation']) {
- 						this.doGetLocation();
- 					}
- 				},
- 				fail: (err) => {}
- 			})
- 		}
- 		// async checkPermission() {
- 		// 	let status = permision.isIOS ? await permision.requestIOS('location') :
- 		// 		await permision.requestAndroid('android.permission.ACCESS_FINE_LOCATION');
-
- 		// 	if (status === null || status === 1) {
- 		// 		status = 1;
- 		// 	} else if (status === 2) {
- 		// 		uni.showModal({
- 		// 			content: "系统定位已关闭",
- 		// 			confirmText: "确定",
- 		// 			showCancel: false,
- 		// 			success: function(res) {}
- 		// 		})
- 		// 	} else if (status.code) {
- 		// 		uni.showModal({
- 		// 			content: status.message
- 		// 		})
- 		// 	} else {
- 		// 		uni.showModal({
- 		// 			content: "需要定位权限",
- 		// 			confirmText: "设置",
- 		// 			success: function(res) {
- 		// 				if (res.confirm) {
- 		// 					permision.gotoAppSetting();
- 		// 				}
- 		// 			}
- 		// 		})
- 		// 	}
- 		// 	return status;
- 		// },
- 	}
-
- }

Some files were not shown because too many files changed in this diff