Sfoglia il codice sorgente

Merge branch 'master' of ssh://gogs.zfire.top:2222/zfire-front/recycle-mobile

* 'master' of ssh://gogs.zfire.top:2222/zfire-front/recycle-mobile:
  no message
  no message
Moss 1 anno fa
parent
commit
f90da77ffb
6 ha cambiato i file con 323 aggiunte e 294 eliminazioni
  1. 29 21
      src/App.vue
  2. 177 174
      src/common/utils/common.js
  3. 3 3
      src/common/utils/navPag.js
  4. 6 4
      src/pages.json
  5. 94 92
      src/pages/index/index.vue
  6. 14 0
      src/pages/message/index.vue

+ 29 - 21
src/App.vue

@@ -1,5 +1,6 @@
 <script>
   import Vue from 'vue';
+  import store from '@/store/index.js'
   // 解析地址栏参数
   function getQueryVariable(variable) {
     // 从?开始获取后面的所有数据
@@ -19,32 +20,39 @@
   }
   export default {
     onLaunch: function() {
-      uni.getSystemInfo({
-      	success: function(e) {
-      		console.log(e);
-      		Vue.prototype.StatusBar = e.statusBarHeight;
-      		// #ifdef MP-WEIXIN
-      		let custom = wx.getMenuButtonBoundingClientRect();
-      		Vue.prototype.Custom = custom;
-      		Vue.prototype.CustomBar = custom.bottom + custom.top - e.statusBarHeight + 4;
-      		// #endif
-          // #ifndef MP-WEIXIN
-          Vue.prototype.CustomBar = 48
-          // #endif
-      		//用来判断是否iphoneX类型的全面屏设备
-      		if (e.model.indexOf('iPhone X') == 0) {
-      			Vue.prototype.isIphoneX = 68;
-      		} else {
-      			Vue.prototype.isIphoneX = 0;
-      		}
-      	},
+      // #ifdef H5
+      var token = getQueryVariable("x-token")
+      if (token) {
+        store.commit("set_token", token)
+      }
+      // #endif
+
+      uni.getSystemInfo({
+        success: function(e) {
+          console.log(e);
+          Vue.prototype.StatusBar = e.statusBarHeight;
+          // #ifdef MP-WEIXIN
+          let custom = wx.getMenuButtonBoundingClientRect();
+          Vue.prototype.Custom = custom;
+          Vue.prototype.CustomBar = custom.bottom + custom.top - e.statusBarHeight + 4;
+          // #endif
+          // #ifndef MP-WEIXIN
+          Vue.prototype.CustomBar = 48
+          // #endif
+          //用来判断是否iphoneX类型的全面屏设备
+          if (e.model.indexOf('iPhone X') == 0) {
+            Vue.prototype.isIphoneX = 68;
+          } else {
+            Vue.prototype.isIphoneX = 0;
+          }
+        },
       });
     },
     onShow: function() {
-      // console.log('App Show')
+
     },
     onHide: function() {
-      // console.log('App Hide')
+
     }
   }
 </script>

+ 177 - 174
src/common/utils/common.js

@@ -1,118 +1,117 @@
 // 不含icon提示框
 export const toast = str => {
-	return new Promise((resolve, reject) => {
-		if(str.length < 20) {
-			uni.showToast({
-				title: str,
-				icon: "none",
-				duration: 1500,
-				success: () => {
-					setTimeout(() => {
-						resolve
-					}, 1500)
-				}
-			})
-		}
-		else {
-			uni.showModal({
-				title: "提示",
-				content: String(str),
-				showCancel: false,
-				confirmText: "我知道了",
-				success(res) {
-					if (res.confirm) {
-						resolve(res);
-					} else {
-						reject();
-					}
-				}
-			});
-		}
-	})
+  return new Promise((resolve, reject) => {
+    if (str.length < 20) {
+      uni.showToast({
+        title: str,
+        icon: "none",
+        duration: 1500,
+        success: () => {
+          setTimeout(() => {
+            resolve
+          }, 1500)
+        }
+      })
+    } else {
+      uni.showModal({
+        title: "提示",
+        content: String(str),
+        showCancel: false,
+        confirmText: "我知道了",
+        success(res) {
+          if (res.confirm) {
+            resolve(res);
+          } else {
+            reject();
+          }
+        }
+      });
+    }
+  })
 };
 
 // 成功提示框
 export const successToast = (str) => {
-	return new Promise((resolve, reject) => {
-		uni.showToast({
-			title: str || '请求成功',
-			icon: 'success',
-			duration: 1500,
-			success: () => {
-				setTimeout(() => {
-					resolve();
-				}, 1500);
-			},
-		});
-	});
+  return new Promise((resolve, reject) => {
+    uni.showToast({
+      title: str || '请求成功',
+      icon: 'success',
+      duration: 1500,
+      success: () => {
+        setTimeout(() => {
+          resolve();
+        }, 1500);
+      },
+    });
+  });
 };
 
 // loading
 export const showLoading = () => {
-	return new Promise((resolve, reject) => {
-		uni.showLoading({
-			success: () => {
-				resolve();
-			},
-		});
-	});
+  return new Promise((resolve, reject) => {
+    uni.showLoading({
+      success: () => {
+        resolve();
+      },
+    });
+  });
 };
 
 // 提示loading
 export const tipLoading = (str) => {
-	return new Promise((resolve, reject) => {
-		uni.showLoading({
-			title: str,
-			success: () => {
-				resolve();
-			},
-		});
-	});
+  return new Promise((resolve, reject) => {
+    uni.showLoading({
+      title: str,
+      success: () => {
+        resolve();
+      },
+    });
+  });
 };
 
 // 隐藏loading
 export const hideLoading = () => {
-	return new Promise((resolve, reject) => {
-		uni.hideLoading({
-			success: () => {
-				resolve();
-			},
-		});
-	});
+  return new Promise((resolve, reject) => {
+    uni.hideLoading({
+      success: () => {
+        resolve();
+      },
+    });
+  });
 };
 
 // 模态弹窗
 export const modal = (options = {}) => {
-	if (!options) return;
-	const {
-		title,
-		content,
-		showCancel,
-		cancelText,
-		cancelColor,
-		confirmText,
-		confirmColor,
-	} = Object.assign({}, options.content ? options : {
-		content: options
-	});
-	return new Promise((resolve, reject) => {
-		uni.showModal({
-			title: title || '提示',
-			content: String(content),
-			showCancel: typeof showCancel == 'boolean' ? showCancel : true,
-			cancelText: cancelText || '取消',
-			cancelColor: cancelColor || '#323233',
-			confirmText: confirmText || '确定',
-			confirmColor: confirmColor || '#3D8FFD',
-			complete(res) {
-				if (res.confirm) {
-					resolve(res);
-				} else {
-					reject();
-				}
-			},
-		});
-	});
+  if (!options) return;
+  const {
+    title,
+    content,
+    showCancel,
+    cancelText,
+    cancelColor,
+    confirmText,
+    confirmColor,
+  } = Object.assign({}, options.content ? options : {
+    content: options
+  });
+  return new Promise((resolve, reject) => {
+    uni.showModal({
+      title: title || '提示',
+      content: String(content),
+      showCancel: typeof showCancel == 'boolean' ? showCancel : true,
+      cancelText: cancelText || '取消',
+      cancelColor: cancelColor || '#323233',
+      confirmText: confirmText || '确定',
+      confirmColor: confirmColor || '#3D8FFD',
+      complete(res) {
+        if (res.confirm) {
+          resolve(res);
+        } else {
+          reject();
+        }
+      },
+    });
+  });
 };
 
 /**
@@ -123,18 +122,18 @@ export const modal = (options = {}) => {
  * @returns
  */
 export const navPage = (url, isAuth = 0) => {
-	if ((isAuth && store.state.isLogin) || !isAuth) {
-		uni.navigateTo({
-			url,
-			fail: (err) => {
-				console.log('页面跳转失败', url, err);
-			},
-		});
-	} else {
-		uni.navigateTo({
-			url: '/pages/login/index',
-		});
-	}
+  if ((isAuth && store.state.isLogin) || !isAuth) {
+    uni.navigateTo({
+      url,
+      fail: (err) => {
+        console.log('页面跳转失败', url, err);
+      },
+    });
+  } else {
+    uni.navigateTo({
+      url: '/pages/login/index',
+    });
+  }
 };
 
 /**
@@ -145,18 +144,18 @@ export const navPage = (url, isAuth = 0) => {
  * @returns
  */
 export const redPage = (url, isAuth = 0) => {
-	if ((isAuth && store.state.isLogin) || !isAuth) {
-		uni.redirectTo({
-			url,
-			fail: (err) => {
-				console.log('页面跳转失败', url, err);
-			},
-		});
-	} else {
-		uni.navigateTo({
-			url: '/pages/login/index',
-		});
-	}
+  if ((isAuth && store.state.isLogin) || !isAuth) {
+    uni.redirectTo({
+      url,
+      fail: (err) => {
+        console.log('页面跳转失败', url, err);
+      },
+    });
+  } else {
+    uni.navigateTo({
+      url: '/pages/login/index',
+    });
+  }
 };
 
 /**
@@ -166,12 +165,12 @@ export const redPage = (url, isAuth = 0) => {
  * @returns
  */
 export const backPage = (num = 1, time = 0) => {
-	if (!num) return false;
-	setTimeout(() => {
-		uni.navigateBack({
-			delta: num,
-		});
-	}, time);
+  if (!num) return false;
+  setTimeout(() => {
+    uni.navigateBack({
+      delta: num,
+    });
+  }, time);
 };
 
 /**
@@ -180,19 +179,19 @@ export const backPage = (num = 1, time = 0) => {
  * @param {String} orderId 服务单id,如果需要请求记录接口
  */
 export const callPhone = (phone) => {
-	if (!phone)
-		return modal({
-				content: '手机号码不存在',
-				showCancel: false,
-			})
-			.then(() => {})
-			.catch(() => {});
-	uni.makePhoneCall({
-		phoneNumber: phone,
-		success: () => {
-			// logCallPhone(orderId);
-		},
-	});
+  if (!phone)
+    return modal({
+        content: '手机号码不存在',
+        showCancel: false,
+      })
+      .then(() => {})
+      .catch(() => {});
+  uni.makePhoneCall({
+    phoneNumber: phone,
+    success: () => {
+      // logCallPhone(orderId);
+    },
+  });
 };
 
 /**
@@ -200,53 +199,57 @@ export const callPhone = (phone) => {
  * @param {String} val 复制内容
  */
 export const copy = (val) => {
-	uni.setClipboardData({
-		data: val,
-		success: () => {
-			successToast('复制成功');
-		},
-	});
+  uni.setClipboardData({
+    data: val,
+    success: () => {
+      successToast('复制成功');
+    },
+  });
 };
 
 // 判断微信环境
 export function isWeixin() {
-	var ua = navigator.userAgent.toLowerCase();
-	if (ua.indexOf('micromessenger') != -1) {
-		return true;
-	} else {
-		return false;
-	}
+  if (navigator && navigator.userAgent) {
+    var ua = navigator.userAgent.toLowerCase();
+    if (ua.indexOf('micromessenger') != -1) {
+      return true;
+    } else {
+      return false;
+    }
+  } else {
+    return false
+  }
 }
 
 // 解析地址栏参数
 export function getQueryVariable(variable) {
-	// 从?开始获取后面的所有数据
-	var query = window.location.search.substring(1);
-	// 从字符串&开始分隔成数组split
-	var vars = query.split('&');
-	// 遍历该数组
-	for (var i = 0; i < vars.length; i++) {
-		// 从等号部分分割成字符
-		var pair = vars[i].split('=');
-		// 如果第一个元素等于 传进来的参的话 就输出第二个元素
-		if (pair[0] == variable) {
-		return pair[1];
-		}
-	}
-	return undefined;
+  // 从?开始获取后面的所有数据
+  var query = window.location.search.substring(1);
+  // 从字符串&开始分隔成数组split
+  var vars = query.split('&');
+  // 遍历该数组
+  for (var i = 0; i < vars.length; i++) {
+    // 从等号部分分割成字符
+    var pair = vars[i].split('=');
+    // 如果第一个元素等于 传进来的参的话 就输出第二个元素
+    if (pair[0] == variable) {
+      return pair[1];
+    }
+  }
+  return undefined;
 }
 
 
 export default {
-	toast,
-	successToast,
-	showLoading,
-	tipLoading,
-	hideLoading,
-	modal,
-	navPage,
-	redPage,
-	backPage,
-	callPhone,
-	copy
-};
+  toast,
+  successToast,
+  showLoading,
+  tipLoading,
+  hideLoading,
+  modal,
+  navPage,
+  redPage,
+  backPage,
+  callPhone,
+  copy
+};

+ 3 - 3
src/common/utils/navPag.js

@@ -63,8 +63,8 @@ export const navToPage = (function() {
 
 export function webViewHref(url) {
   if (!!~url.indexOf("?")) {
-    return process.env.VUE_APP_HREF + url + "&x-token=" + store.getters.token
+    return process.env.VUE_APP_HREF + url + "&x-token=123" + store.getters.token
   } else {
-    return process.env.VUE_APP_HREF + url + "?x-token=" + store.getters.token
+    return process.env.VUE_APP_HREF + url + "?x-token=123" + store.getters.token
   }
-}
+}

+ 6 - 4
src/pages.json

@@ -11,8 +11,10 @@
     {
       "path": "pages/index/index",
       "style": {
-        "navigationStyle": "custom",
-        "navigationBarTitleText": "首页"
+        "navigationBarTitleText": "二手空调",
+        // "navigationStyle": "custom",
+        "navigationBarTextStyle":"#fff",
+        "navigationBarBackgroundColor":"#01C30B"
       }
     },
 
@@ -118,7 +120,7 @@
       "style": {
         "navigationBarTitleText": "订单详情"
       }
-    },
+    },
     {
       "path": "pages/goods/list",
       "style": {
@@ -196,4 +198,4 @@
       }
     ]
   }
-}
+}

+ 94 - 92
src/pages/index/index.vue

@@ -2,33 +2,20 @@
   <!-- #ifdef H5 -->
   <view>
     <view class="bg-container"></view>
-    <zj-page-layout
-    	:hasFooter="false"
-    	:isScroll="true"
-    	:refresherTriggered="refresherTriggered"
-    	@refresherrefresh="refresherrefresh"
-    	@scrolltolower="scrolltolower">
-      <template slot="header">
+    <zj-page-layout :hasFooter="false" :isScroll="true" :refresherTriggered="refresherTriggered"
+      @refresherrefresh="refresherrefresh" @scrolltolower="scrolltolower">
+      <!-- <template slot="header">
         <view class="header-container" :style="cuStyle">二手空调</view>
-      </template>
+      </template> -->
 
       <view class="all-container">
         <view class="search-container">
-          <u-search
-            placeholder="输入商品名称搜索"
-            :showAction="false"
-            clearabled
-            v-model="keyword">
+          <u-search placeholder="输入商品名称搜索" :showAction="false" clearabled v-model="keyword">
           </u-search>
         </view>
 
         <view class="swiper-container card mt30">
-          <u-swiper
-            :list="bannerList"
-            indicator
-            indicatorMode="line"
-            circular
-          ></u-swiper>
+          <u-swiper :list="bannerList" indicator indicatorMode="line" circular></u-swiper>
         </view>
 
         <view class="category-container card mt30">
@@ -39,11 +26,7 @@
         </view>
 
         <view class="tab-container mt30">
-          <u-tabs
-            :list="tabList"
-            @click="click"
-            :scrollable="false"
-            lineColor="#01C30B">
+          <u-tabs :list="tabList" @click="click" :scrollable="false" lineColor="#01C30B">
           </u-tabs>
         </view>
 
@@ -108,20 +91,31 @@
           'https://cdn.uviewui.com/uview/swiper/swiper2.png',
           'https://cdn.uviewui.com/uview/swiper/swiper1.png',
         ],
-        categoryList: [1,2,3,4],
-        tabList: [
-          {name: '默认顺序', value: 1},
-          {name: '在售商品', value: 2},
-          {name: '离我最近', value: 3},
-          {name: '人气最高', value: 4},
+        categoryList: [1, 2, 3, 4],
+        tabList: [{
+            name: '默认顺序',
+            value: 1
+          },
+          {
+            name: '在售商品',
+            value: 2
+          },
+          {
+            name: '离我最近',
+            value: 3
+          },
+          {
+            name: '人气最高',
+            value: 4
+          },
         ],
       }
     },
-    
-    computed:{
-    	cuStyle(){
-    		return `height:${this.CustomBar-this.StatusBar}px; padding-top:${this.StatusBar}px;`
-    	},
+
+    computed: {
+      cuStyle() {
+        return `height:${this.CustomBar-this.StatusBar}px; padding-top:${this.StatusBar}px;`
+      },
     },
 
     async onLoad() {
@@ -137,31 +131,31 @@
         }).then(res => {
           this.loadStatus = 0;
           let list = res.data.records;
-          if(list.length < 10){
-          	this.loadStatus = 2;
+          if (list.length < 10) {
+            this.loadStatus = 2;
           }
           this.dataList = this.dataList.concat(list);
         }).catch(() => {
-					this.loadStatus = 2;
-				}).finally(res => {
-					this.refresherTriggered = false;
-				})
+          this.loadStatus = 2;
+        }).finally(res => {
+          this.refresherTriggered = false;
+        })
       },
 
       // 滚动到底部
       scrolltolower(e) {
-      	if (this.loadStatus === 0) {
-      		this.pageNum++;
-      		this.getList();
-      	}
+        if (this.loadStatus === 0) {
+          this.pageNum++;
+          this.getList();
+        }
       },
 
       // 触发下拉刷新
       refresherrefresh(e) {
-      	this.refresherTriggered = true;
-      	this.dataList = [];
-      	this.pageNum = 1;
-      	this.getList();
+        this.refresherTriggered = true;
+        this.dataList = [];
+        this.pageNum = 1;
+        this.getList();
       },
 
     }
@@ -169,50 +163,58 @@
 </script>
 
 <style lang="scss" scoped>
-.all-container {
-  padding: 0 30rpx 30rpx;
-}
-.header-container {
-  font-size: 32rpx;
-  color: #ffffff;
-  height: 88rpx;
-  display: flex;
-  justify-content: center;
-  align-items: center;
-  font-weight: 600;
-  position: relative;
-}
-.bg-container {
-  position: fixed;
-  top: 0;
-  left: 0;
-  width: 750rpx;
-  height: 750rpx;
-  background: linear-gradient(to bottom, $theme-color, #f4f2f2);
-}
-.card {
-  @include zj-card;
-}
-.swiper-container {
-  border-radius: 20rpx;
-  overflow: hidden;
-}
-.category-container {
-  display: flex;
-  padding: 30rpx 0;
-  .item {
-    width: 25%;
+  .all-container {
+    padding: 0 30rpx 30rpx;
+  }
+
+  .header-container {
+    font-size: 32rpx;
+    color: #ffffff;
+    height: 88rpx;
     display: flex;
+    justify-content: center;
     align-items: center;
-    flex-direction: column;
-    image {
-      width: 44rpx;
-      height: 44rpx;
-    }
-    .name {
-      font-size: 28rpx;
-      margin-top: 16rpx;
+    font-weight: 600;
+    position: relative;
+  }
+
+  .bg-container {
+    position: fixed;
+    top: 0;
+    left: 0;
+    width: 750rpx;
+    height: 750rpx;
+    background: linear-gradient(to bottom, $theme-color, #f4f2f2);
+  }
+
+  .card {
+    @include zj-card;
+  }
+
+  .swiper-container {
+    border-radius: 20rpx;
+    overflow: hidden;
+  }
+
+  .category-container {
+    display: flex;
+    padding: 30rpx 0;
+
+    .item {
+      width: 25%;
+      display: flex;
+      align-items: center;
+      flex-direction: column;
+
+      image {
+        width: 44rpx;
+        height: 44rpx;
+      }
+
+      .name {
+        font-size: 28rpx;
+        margin-top: 16rpx;
+      }
     }
   }
-}
-</style>
+</style>

+ 14 - 0
src/pages/message/index.vue

@@ -44,7 +44,21 @@
 <script>
   export default {
     // #ifdef H5
+    data() {
+      return {
+        scrollTop: 0,
+      }
+    },
     methods: {
+      upper() {
+        console.log("顶")
+      },
+      lower() {
+        console.log("底")
+      },
+      scroll(e) {
+        this.scrollTop = e.detail.scrollTop
+      },
       goMsgView() {
         this.$navToPage({
           url: '/pages/message/msgView'