浏览代码

添加个人信息积分

Wang-Xiao-Ran 1 年之前
父节点
当前提交
3d1c737c7e
共有 6 个文件被更改,包括 265 次插入40 次删除
  1. 1 0
      App.vue
  2. 2 2
      manifest.json
  3. 8 0
      pages.json
  4. 136 0
      pages/me/me.css
  5. 115 37
      pages/me/me.vue
  6. 3 1
      store/modules/user.js

+ 1 - 0
App.vue

@@ -23,6 +23,7 @@
       checkLogin() {
         if (!getToken()) {
           this.$tab.reLaunch('/pages/login') 
+          // this.$tab.reLaunch('/pages/me/me.vue') 
         }
       }
     }

+ 2 - 2
manifest.json

@@ -42,7 +42,7 @@
             "sdkConfigs" : {
                 "oauth" : {
                     "weixin" : {
-                        "appid" : "wxf75b34dd1f737174",
+                        "appid" : "wx7abed48bcc12427c",
                         "UniversalLinks" : ""
                     }
                 }
@@ -51,7 +51,7 @@
     },
     "quickapp" : {},
     "mp-weixin" : {
-        "appid" : "wx0904bdfd9c082418",
+        "appid" : "wx7abed48bcc12427c",
         "setting" : {
             "urlCheck" : false
         },

+ 8 - 0
pages.json

@@ -94,6 +94,14 @@
 				"navigationBarTextStyle": "white",
 				"navigationBarTitleText": "商品详情页"
 			}
+		},
+		{
+			"path" : "pages/me/meOperate",
+			"style" : 
+			{
+				"navigationBarTitleText" : "",
+				"enablePullDownRefresh" : false
+			}
 		}
 	],
 	"tabBar": {

+ 136 - 0
pages/me/me.css

@@ -1 +1,137 @@
 /* pages/me.wxss */
+/* #ifndef APP-PLUS-NVUE */
+page {
+    min-height: 100%;
+    height: auto;
+}
+/* #endif */
+
+/* 解决头条小程序字体图标不显示问题,因为头条运行时自动插入了span标签,且有全局字体 */
+/* #ifdef MP-TOUTIAO */
+/* text :not(view) {
+    font-family: uniicons;
+} */
+/* #endif */
+
+.uni-icon {
+    font-family: uniicons;
+    font-weight: normal;
+}
+
+.uni-container {
+    padding: 15px;
+    background-color: #f8f8f8;
+}
+
+.uni-header-logo {
+	/* #ifdef H5 */
+	display: flex;
+	/* #endif */
+    padding: 15px 15px;
+    flex-direction: column;
+    justify-content: center;
+    align-items: center;
+    margin-top: 10rpx;
+}
+
+.uni-header-image {
+    width: 80px;
+    height: 80px;
+}
+
+.uni-hello-text {
+    margin-bottom: 20px;
+}
+
+.hello-text {
+    color: #7A7E83;
+    font-size: 14px;
+    line-height: 20px;
+}
+
+.hello-link {
+    color: #7A7E83;
+    font-size: 14px;
+    line-height: 20px;
+}
+
+.uni-panel {
+    margin-bottom: 12px;
+}
+
+.uni-panel-h {
+	/* #ifdef H5 */
+	display: flex;
+	/* #endif */
+    background-color: #ffffff;
+    flex-direction: row !important;
+	/* justify-content: space-between !important; */
+    align-items: center !important;
+    padding: 12px;
+	/* #ifdef H5 */
+	cursor: pointer;
+	/* #endif */
+}
+/*
+.uni-panel-h:active {
+    background-color: #f8f8f8;
+}
+ */
+.uni-panel-h-on {
+    background-color: #f0f0f0;
+}
+
+.uni-panel-text {
+    flex: 1;
+    color: #000000;
+    font-size: 14px;
+    font-weight: normal;
+}
+
+.uni-panel-icon {
+    margin-left: 15px;
+    color: #999999;
+    font-size: 14px;
+    font-weight: normal;
+    transform: rotate(0deg);
+    transition-duration: 0s;
+    transition-property: transform;
+}
+
+.uni-panel-icon-on {
+    transform: rotate(180deg);
+}
+
+.uni-navigate-item {
+	/* #ifdef H5 */
+	display: flex;
+	/* #endif */
+    flex-direction: row;
+    align-items: center;
+    background-color: #FFFFFF;
+    border-top-style: solid;
+    border-top-color: #f0f0f0;
+    border-top-width: 1px;
+    padding: 12px;
+	/* #ifdef H5 */
+	cursor: pointer;
+	/* #endif */
+}
+
+.uni-navigate-item:active {
+    background-color: #f8f8f8;
+}
+
+.uni-navigate-text {
+    flex: 1;
+    color: #000000;
+    font-size: 14px;
+    font-weight: normal;
+}
+
+.uni-navigate-icon {
+    margin-left: 15px;
+    color: #999999;
+    font-size: 14px;
+    font-weight: normal;
+}

+ 115 - 37
pages/me/me.vue

@@ -1,46 +1,124 @@
 <template>
-    <!-- pages/me.wxml -->
+	<!-- pages/me.wxml -->
+	<view class="uni-container">
+		<view class="uni-header-logo">
+			<img class="uni-header-image" :src="initInfo.headImg == null || initInfo.headImg == '' ? 'http://116.142.80.12:9000/10_03.png' : initInfo.headImg" />
+			<span>{{initInfo.name == null || initInfo.name == '' ? initInfo.wechatName : initInfo.name}}</span>
+			<text>{{initInfo.scoreNum}}</text>
+		</view>
+		<view class="uni-panel" v-for="(item, index) in list" :key="item.id">
+			<view class="uni-panel-h" :class="item.open ? 'uni-panel-h-on' : ''" @click="goDetailPage(index, item.id)">
+				<text class="uni-panel-text">{{item.name}}</text>
+				<text class="uni-panel-icon uni-icon" :class="item.open ? 'uni-panel-icon-on' : ''">{{item.pages ? '&#xe581;' : '&#xe470;'}}</text>
+			</view>
+		</view>
+	</view>
 </template>
 
 <script>
+import {getScore, getUserInfo} from '@/api/me/me.js'
 // pages/me.js
 export default {
-    data() {
-        return {};
-    }
-    /**
-     * 生命周期函数--监听页面加载
-     */,
-    onLoad(options) {},
-    /**
-     * 生命周期函数--监听页面初次渲染完成
-     */
-    onReady() {},
-    /**
-     * 生命周期函数--监听页面显示
-     */
-    onShow() {},
-    /**
-     * 生命周期函数--监听页面隐藏
-     */
-    onHide() {},
-    /**
-     * 生命周期函数--监听页面卸载
-     */
-    onUnload() {},
-    /**
-     * 页面相关事件处理函数--监听用户下拉动作
-     */
-    onPullDownRefresh() {},
-    /**
-     * 页面上拉触底事件的处理函数
-     */
-    onReachBottom() {},
-    /**
-     * 用户点击右上角分享
-     */
-    onShareAppMessage() {},
-    methods: {}
+	data() {
+		return {
+			initInfo:{
+				userId: null,
+				scoreNum: 0,
+				wechatName: "微信用户",
+				name: null,
+				headImg: null,
+			},
+			list: [
+				{
+					id: 'me/meOperate',//id是文件路径
+					name: '我的积分流水',
+					open: false,
+					pages: ['meOperate']
+				},
+				{
+					id: 'wenba/wenba',
+					name: '我的问答',
+					open: false,
+					pages: ['meOperate']
+				}
+			]
+		};
+	},
+	/**
+	 * 生命周期函数--监听页面加载
+	 */ onLoad(options) {},
+	/**
+	 * 生命周期函数--监听页面初次渲染完成
+	 */
+	onReady() {
+		this.userId = getApp().globalData.userId
+		this.getUserInfoByUserId(this.userId)
+		this.getScoreForMe(this.userId)
+	},
+	/**
+	 * 生命周期函数--监听页面显示
+	 */
+	onShow() {},
+	/**
+	 * 生命周期函数--监听页面隐藏
+	 */
+	onHide() {},
+	/**
+	 * 生命周期函数--监听页面卸载
+	 */
+	onUnload() {},
+	/**
+	 * 页面相关事件处理函数--监听用户下拉动作
+	 */
+	onPullDownRefresh() {},
+	/**
+	 * 页面上拉触底事件的处理函数
+	 */
+	onReachBottom() {},
+	/**
+	 * 用户点击右上角分享
+	 */
+	onShareAppMessage() {},
+	methods: {
+		goDetailPage(panel, e) {
+			if (typeof e === 'string') {
+				const url = '/pages/' + e
+				if (this.hasLeftWin) {
+					uni.reLaunch({
+						url: url
+					})
+				} else {
+					uni.navigateTo({
+						url: url
+					})
+				}
+			} else {
+				if (this.hasLeftWin) {
+					uni.reLaunch({
+						url: e.url
+					})
+				} else {
+					uni.navigateTo({
+						url: e.url
+					})
+				}
+			}
+		},
+		//获取用户信息:用户名称:头像
+		getUserInfoByUserId(userId){
+			getUserInfo(userId).then(res =>{
+				this.initInfo.wechatName = res.data.wechatName;
+				this.initInfo.name = res.data.name;
+				this.initInfo.wechatName = res.data.wechatName;
+			})
+		},
+		//获取当前积分
+		getScoreForMe(userId){
+			getScore(this.userId).then(res =>{
+				this.initInfo.socreNum = res.data.scoreNum
+			})
+		}
+	}
 };
 </script>
 <style>

+ 3 - 1
store/modules/user.js

@@ -42,7 +42,9 @@ const user = {
     Login({ commit }, code) {
       return new Promise((resolve, reject) => {
         wxLogin(code).then(res => {
-          setToken(res.token)
+          setToken(res.data.token)
+		  //全局设置userId
+		  getApp().globalData.userId= res.data.userId
           commit('SET_TOKEN', res.token)
           resolve()
         }).catch(error => {