shish 1 سال پیش
والد
کامیت
4f14aed641
3فایلهای تغییر یافته به همراه120 افزوده شده و 2 حذف شده
  1. 5 1
      mallApp/src/api/user/index.js
  2. 29 0
      mallApp/src/pages/home/recent.vue
  3. 86 1
      mallApp/src/utils/util.js

+ 5 - 1
mallApp/src/api/user/index.js

@@ -18,4 +18,8 @@ export const create = data => {
 
 export const accountLogin = data => {
 	return https.get('/user/account-login', data)
-}
+}
+
+export const clearLogin = data => {
+	return https.get("/user/clear-login", data);
+};

+ 29 - 0
mallApp/src/pages/home/recent.vue

@@ -11,6 +11,15 @@
 
 
       <view class="ghs_list_page flex-col" v-if="!$util.isEmpty(list)">
+
+        <view style="background-color:white;margin-bottom:20upx;">
+          <button class="admin-button-com mini-btn blue" style="margin-left:9upx;padding-top:18upx;padding-bottom:18upx;border:none;margin-top:10upx;" @click="">修改密码</button>
+          <button class="admin-button-com mini-btn blue" style="margin-left:9upx;padding-top:18upx;padding-bottom:18upx;border:none;margin-top:10upx;" @click="">改进建议</button>
+          <button class="admin-button-com mini-btn blue" style="margin-left:9upx;padding-top:18upx;padding-bottom:18upx;border:none;margin-top:10upx;" @click="">我的地址</button>
+          <button class="admin-button-com mini-btn blue" style="margin-left:9upx;padding-top:18upx;padding-bottom:18upx;border:none;margin-top:10upx;" @click="">采购统计</button>
+          <button class="admin-button-com mini-btn blue" style="margin-left:9upx;padding-top:18upx;padding-bottom:18upx;border:none;margin-top:10upx;" @click="logout()">退出登录</button>
+        </view>
+
         <view class="ghs_list_area flex-col justify-end">
 
             <view class="ghs_box flex-col justify-end" v-for="item in list" :key="item.id">
@@ -87,6 +96,7 @@ import { getList } from "@/api/hd";
 import { share } from "@/mixins";
 import AppAvatarModule from "@/components/module/app-avatar";
 import { mapGetters } from 'vuex'
+import { clearLogin } from "@/api/user";
 export default {
   name: "recent",
   components: { AppAvatarModule, AppSwiper, TuiListView, TuiListCell, AppActivilyCoupon },
@@ -123,6 +133,25 @@ export default {
   onLoad () {
   },
   methods: {
+    logout(){
+      let that = this
+      that.$util.confirmModal({content:'确认退出?'},() => {
+        // #ifdef APP-PLUS
+        uni.clearStorage()
+        that.$store.commit("setLoginInfo", {})
+        plus.runtime.restart()
+        // #endif
+        // #ifdef MP-WEIXIN
+        clearLogin().then(res=>{
+          if(res.code == 1){
+            uni.clearStorage()
+            that.$store.commit("setLoginInfo", {})
+            uni.reLaunch({url:'/pages/home/recent'})
+          }
+        })
+        // #endif
+      })
+    },
     getBuyList(){
       this.pageTo({ url:'/pages/order/list'})
     },

+ 86 - 1
mallApp/src/utils/util.js

@@ -267,7 +267,91 @@ export const unique = (arr) => {
 	}
 	return arr;
 };
-	
+
+//#ifdef APP-PLUS
+const CLDialog=uni.requireNativePlugin("CL-Dialog")
+//#endif
+export const confirmModal = (item,okCallback=null,cancelCallback=null) => {
+
+	let title = item.title || '提示'
+	let content = item.content || '确认操作?'
+	let okText = item.okText || '确认'
+	let cancelText = item.cancelText || '取消'
+	let cacelTextColor = '#999999'
+	let okTextColor = '#38ADFF'
+	let singer = item.singer || false
+
+	//#ifdef APP-PLUS
+	let platform=uni.getSystemInfoSync().platform
+    if(platform=='ios'){
+		uni.showModal({
+			title: title,
+			content: content,
+			showCancel: true,
+			cancelText: cancelText,
+			cancelColor: cacelTextColor,
+			confirmText: okText,
+			confirmColor: okTextColor,
+			success: function (res) {
+				if (res.confirm) {
+					if(okCallback!=null){
+						okCallback()
+					}
+				} else if (res.cancel) {
+					if(cancelCallback!=null){
+						cancelCallback()
+					}
+				}
+			}
+		})          
+    }else if(platform=='android'){
+		let options={
+			title:title,//内容(可选)但是标题和内容至少选择一个
+			con:content,
+			okTitle:okText,//确认按钮文字(可选)
+			cancleTitle:cancelText,//取消按钮文字(可选)
+			okTextColor:"#38ADFF",//确认按钮颜色(可选)
+			cancleTextColor:"#999999",//取消按钮颜色(可选)
+			singer:singer,//是否只显示确认按钮,默认false(可选)
+			textAlign:"center",//对齐方式 //left居左,center居中,right 居右 默认居中
+			conColor:"",
+			bgColor:"#FFFFFF",//自定义弹框颜色
+			titleColor:"#3d3d3d"//自定义title颜色
+		}
+		CLDialog.show(options,()=>{
+			if(okCallback!=null){
+				okCallback()
+			}
+		},()=>{
+			if(cancelCallback!=null){
+				cancelCallback()
+			}
+		})
+	}
+	//#endif
+	// #ifdef MP-WEIXIN
+	uni.showModal({
+		title: title,
+		content: content,
+		showCancel: true,
+		cancelText: cancelText,
+		cancelColor: cacelTextColor,
+		confirmText: okText,
+		confirmColor: okTextColor,
+		success: function (res) {
+			if (res.confirm) {
+				if(okCallback!=null){
+					okCallback()
+				}
+			} else if (res.cancel) {
+				if(cancelCallback!=null){
+					cancelCallback()
+				}
+			}
+		}
+	})
+	//#endif
+}
 
 export default {
 	isEmpty,
@@ -283,4 +367,5 @@ export default {
 	isLogin,
 	getCheckLogin,
 	unique,
+	confirmModal,
 }