zsydgithub 1 年之前
父节点
当前提交
c223bc035e

+ 45 - 0
vue-admin-template-master/src/api/message.js

@@ -0,0 +1,45 @@
+import request from '@/utils/request'
+
+/* 获取全部信息 */
+export function getMessage() {
+  return request({
+    url: '/showMessage',
+    method: 'get'
+  })
+}
+
+/* 添加信息 */
+export function addMessage(data) {
+  return request({
+    url: '/insertAllMessage',
+    method: 'post',
+    data
+  })
+}
+
+/* 显示单条信息 */
+export function showMessage(params) {
+  return request({
+    url: '/showOneMessage',
+    method: 'get',
+    params
+  })
+}
+
+/* 信息修改 */
+export function updateInfo(data) {
+  return request({
+    url: '/updateMessage',
+    method: 'post',
+    data
+  })
+}
+
+/* 根据地址去筛选 */
+export function searchInfo(data) {
+  return request({
+    url: '/searchaddressid',
+    method: 'post',
+    data
+  })
+}

+ 1 - 0
vue-admin-template-master/src/icons/svg/message.svg

@@ -0,0 +1 @@
+<svg t="1705885583038" class="icon" viewBox="0 0 1193 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4243" width="64" height="64"><path d="M1097.791574 928.638581H95.929047v-794.678492l403.015521 332.062084a142.474501 142.474501 0 0 0 101.037694 44.842572 142.474501 142.474501 0 0 0 101.605321-42.572062l397.339246-330.926829v794.678492zM995.050998 95.929047l-356.470067 298.004434a47.68071 47.68071 0 0 1-34.625277 14.758315A47.68071 47.68071 0 0 1 567.627494 397.339246L199.237251 95.929047zM1097.791574 0H95.929047A95.929047 95.929047 0 0 0 0 95.929047v832.709534A95.929047 95.929047 0 0 0 95.929047 1021.72949h1001.862527A95.929047 95.929047 0 0 0 1192.017738 928.638581V95.929047A95.929047 95.929047 0 0 0 1097.791574 0z" fill="#f49329" p-id="4244"></path></svg>

+ 129 - 62
vue-admin-template-master/src/router/index.js

@@ -30,8 +30,7 @@ import Layout from '@/layout'
  * a base page that does not have permission requirements
  * all roles can be accessed
  */
-export const constantRoutes = [
-  {
+export const constantRoutes = [{
     path: '/login',
     component: () => import('@/views/login/index'),
     hidden: true
@@ -51,7 +50,10 @@ export const constantRoutes = [
       path: 'dashboard',
       name: 'Dashboard',
       component: () => import('@/views/dashboard/index'),
-      meta: { title: 'Dashboard', icon: 'dashboard' }
+      meta: {
+        title: 'Dashboard',
+        icon: 'dashboard'
+      }
     }]
   },
 
@@ -60,19 +62,27 @@ export const constantRoutes = [
     component: Layout,
     redirect: '/example/table',
     name: 'Example',
-    meta: { title: 'Example', icon: 'el-icon-s-help' },
-    children: [
-      {
+    meta: {
+      title: 'Example',
+      icon: 'el-icon-s-help'
+    },
+    children: [{
         path: 'table',
         name: 'Table',
         component: () => import('@/views/table/index'),
-        meta: { title: 'Table', icon: 'table' }
+        meta: {
+          title: 'Table',
+          icon: 'table'
+        }
       },
       {
         path: 'tree',
         name: 'Tree',
         component: () => import('@/views/tree/index'),
-        meta: { title: 'Tree', icon: 'tree' }
+        meta: {
+          title: 'Tree',
+          icon: 'tree'
+        }
       }
     ]
   },
@@ -80,52 +90,91 @@ export const constantRoutes = [
   {
     path: '/form',
     component: Layout,
-    children: [
-      {
-        path: 'index',
-        name: 'Form',
-        component: () => import('@/views/form/index'),
-        meta: { title: 'Form', icon: 'form' }
+    children: [{
+      path: 'index',
+      name: 'Form',
+      component: () => import('@/views/form/index'),
+      meta: {
+        title: 'Form',
+        icon: 'form'
       }
-    ]
+    }]
   },
   {
     path: '/level',
     component: Layout,
-    meta: { title: 'Level', icon: 'level' },
-    children: [
-      {
-        path: 'levelList',
-        name: 'levelList',
-        component: () => import('@/views/level/levelList'),
-        meta: { title: '等级列表', icon: 'level' }
-      },{
-        path: 'addLevel',
-        name: 'addLevel',
-        component: () => import('@/views/level/addLevel'),
-        meta: { title: '添加等级', icon: 'level' }
+    meta: {
+      title: 'Level',
+      icon: 'level'
+    },
+    children: [{
+      path: 'levelList',
+      name: 'levelList',
+      component: () => import('@/views/level/levelList'),
+      meta: {
+        title: '等级列表',
+        icon: 'level'
       }
-    ]
+    }, {
+      path: 'addLevel',
+      name: 'addLevel',
+      component: () => import('@/views/level/addLevel'),
+      meta: {
+        title: '添加等级',
+        icon: 'level'
+      }
+    }]
   },
   {
     path: '/location',
     component: Layout,
-    meta: { title: 'Location', icon: 'location' },
-    children: [
-      {
-        path: 'locationList',
-        name: 'locationList',
-        component: () => import('@/views/location/locationList'),
-        meta: { title: '地址列表', icon: 'location' }
-      },{
-        path: 'addLocation',
-        name: 'addLocation',
-        component: () => import('@/views/location/addLocation'),
-        meta: { title: '添加地址', icon: 'location' }
+    meta: {
+      title: 'Location',
+      icon: 'location'
+    },
+    children: [{
+      path: 'locationList',
+      name: 'locationList',
+      component: () => import('@/views/location/locationList'),
+      meta: {
+        title: '地址列表',
+        icon: 'location'
       }
-    ]
+    }, {
+      path: 'addLocation',
+      name: 'addLocation',
+      component: () => import('@/views/location/addLocation'),
+      meta: {
+        title: '添加地址',
+        icon: 'location'
+      }
+    }]
+  },
+  {
+    path: '/message',
+    component: Layout,
+    meta: {
+      title: 'Message',
+      icon: 'message'
+    },
+    children: [{
+      path: 'messageList',
+      name: 'messageList',
+      component: () => import('@/views/message/messageList'),
+      meta: {
+        title: '地址列表',
+        icon: 'message'
+      }
+    }, {
+      path: 'addMessage',
+      name: 'addMessage',
+      component: () => import('@/views/message/addMessage'),
+      meta: {
+        title: '添加地址',
+        icon: 'message'
+      }
+    }]
   },
-
   {
     path: '/nested',
     component: Layout,
@@ -135,36 +184,43 @@ export const constantRoutes = [
       title: 'Nested',
       icon: 'nested'
     },
-    children: [
-      {
+    children: [{
         path: 'menu1',
         component: () => import('@/views/nested/menu1/index'), // Parent router-view
         name: 'Menu1',
-        meta: { title: 'Menu1' },
-        children: [
-          {
+        meta: {
+          title: 'Menu1'
+        },
+        children: [{
             path: 'menu1-1',
             component: () => import('@/views/nested/menu1/menu1-1'),
             name: 'Menu1-1',
-            meta: { title: 'Menu1-1' }
+            meta: {
+              title: 'Menu1-1'
+            }
           },
           {
             path: 'menu1-2',
             component: () => import('@/views/nested/menu1/menu1-2'),
             name: 'Menu1-2',
-            meta: { title: 'Menu1-2' },
-            children: [
-              {
+            meta: {
+              title: 'Menu1-2'
+            },
+            children: [{
                 path: 'menu1-2-1',
                 component: () => import('@/views/nested/menu1/menu1-2/menu1-2-1'),
                 name: 'Menu1-2-1',
-                meta: { title: 'Menu1-2-1' }
+                meta: {
+                  title: 'Menu1-2-1'
+                }
               },
               {
                 path: 'menu1-2-2',
                 component: () => import('@/views/nested/menu1/menu1-2/menu1-2-2'),
                 name: 'Menu1-2-2',
-                meta: { title: 'Menu1-2-2' }
+                meta: {
+                  title: 'Menu1-2-2'
+                }
               }
             ]
           },
@@ -172,7 +228,9 @@ export const constantRoutes = [
             path: 'menu1-3',
             component: () => import('@/views/nested/menu1/menu1-3'),
             name: 'Menu1-3',
-            meta: { title: 'Menu1-3' }
+            meta: {
+              title: 'Menu1-3'
+            }
           }
         ]
       },
@@ -180,7 +238,9 @@ export const constantRoutes = [
         path: 'menu2',
         component: () => import('@/views/nested/menu2/index'),
         name: 'Menu2',
-        meta: { title: 'menu2' }
+        meta: {
+          title: 'menu2'
+        }
       }
     ]
   },
@@ -188,21 +248,28 @@ export const constantRoutes = [
   {
     path: 'external-link',
     component: Layout,
-    children: [
-      {
-        path: 'https://panjiachen.github.io/vue-element-admin-site/#/',
-        meta: { title: 'External Link', icon: 'link' }
+    children: [{
+      path: 'https://panjiachen.github.io/vue-element-admin-site/#/',
+      meta: {
+        title: 'External Link',
+        icon: 'link'
       }
-    ]
+    }]
   },
 
   // 404 page must be placed at the end !!!
-  { path: '*', redirect: '/404', hidden: true }
+  {
+    path: '*',
+    redirect: '/404',
+    hidden: true
+  }
 ]
 
 const createRouter = () => new Router({
   // mode: 'history', // require service support
-  scrollBehavior: () => ({ y: 0 }),
+  scrollBehavior: () => ({
+    y: 0
+  }),
   routes: constantRoutes
 })
 

+ 192 - 0
vue-admin-template-master/src/views/message/addMessage.vue

@@ -0,0 +1,192 @@
+/* 
+  添加信息
+  author: zsy
+  date: 2024-1-22
+*/
+<template>
+  <div class="add-message">
+    <el-form
+      :model="ruleForm"
+      :rules="rules"
+      ref="ruleForm"
+      label-width="100px"
+      class="demo-ruleForm"
+    >
+      <el-form-item label="用户名称" prop="uname">
+        <el-input v-model="ruleForm.uname"></el-input>
+      </el-form-item>
+      <el-form-item label="地址ID" prop="addressid">
+        <el-select v-model="ruleForm.addressid" placeholder="请选择活动区域">
+          <el-option
+            v-for="item in addressData"
+            :key="item.addressid"
+            :value="item.addressid"
+            :label="item.addressname"
+          ></el-option>
+        </el-select>
+      </el-form-item>
+      <el-form-item label="等级ID" prop="levelid">
+        <el-select v-model="ruleForm.levelid" placeholder="请选择活动区域">
+          <el-option
+            v-for="item in levelData"
+            :key="item.jrid"
+            :value="item.jrid"
+            :label="item.levelname"
+          ></el-option>
+        </el-select>
+      </el-form-item>
+      <el-form-item label="电话号码" prop="tel">
+        <el-input v-model="ruleForm.tel"></el-input>
+      </el-form-item>
+      <el-form-item>
+        <el-button
+          type="primary"
+          @click="updateForm('ruleForm')"
+          v-if="isUpdate"
+          >修改</el-button
+        >
+        <el-button type="primary" @click="submitForm('ruleForm')" v-else
+          >提交</el-button
+        >
+        <el-button @click="resetForm('ruleForm')">重置</el-button>
+      </el-form-item>
+    </el-form>
+    <!-- {{ this.$router.query.id }} -->
+  </div>
+</template>
+
+<script>
+import { getLocation } from "@/api/location";
+import { getLevel } from "@/api/level";
+import { addMessage, showMessage, updateInfo } from "@/api/message";
+export default {
+  data() {
+    return {
+      ruleForm: {
+        uname: "",
+        addressid: "",
+        levelid: "",
+        tel: "",
+      },
+      rules: {
+        uname: [{ required: true, message: "请输入名称", trigger: "blur" }],
+        addressid: [
+          { required: true, message: "请选择地址", trigger: "change" },
+        ],
+        levelid: [{ required: true, message: "请选择等级", trigger: "change" }],
+        tel: [{ required: true, message: "请输入电话号码", trigger: "blur" }],
+      },
+      addressData: [],
+      levelData: [],
+    };
+  },
+  methods: {
+    submitForm(formName) {
+      this.$refs[formName].validate((valid) => {
+        if (valid) {
+          addMessage({
+            uname: this.ruleForm.uname,
+            addressid: this.ruleForm.addressid,
+            levelid: this.ruleForm.levelid,
+            tel: this.ruleForm.tel,
+          })
+            .then((res) => {
+              this.$message({
+                message: "恭喜你,添加成功",
+                type: "success",
+              });
+              this.$refs[formName].resetFields();
+              this.$router.push("/message/messageList");
+            })
+            .catch((err) => {
+              this.$message.error("添加失败");
+            });
+        } else {
+          console.log("error submit!!");
+          return false;
+        }
+      });
+    },
+    resetForm(formName) {
+      this.$refs[formName].resetFields();
+    },
+    /* 获取地址列表 */
+    getLocationList() {
+      getLocation().then((res) => {
+        console.log(res.data);
+        this.addressData = res.data;
+      });
+    },
+    /* 获取等级列表 */
+    getLevelList() {
+      getLevel().then((res) => {
+        console.log(res.data);
+        this.levelData = res.data;
+      });
+    },
+    //修改
+    updateForm(formName) {
+      this.$refs[formName].validate((valid) => {
+        if (valid) {
+          updateInfo({
+            id: this.$route.query.id,
+            uname: this.ruleForm.uname,
+            addressid: this.ruleForm.addressid,
+            levelid: this.ruleForm.levelid,
+            tel: this.ruleForm.tel,
+          })
+            .then((res) => {
+              this.$message({
+                message: "恭喜你,修改成功",
+                type: "success",
+              });
+              this.$refs[formName].resetFields();
+              this.$router.push("/message/messageList");
+            })
+            .catch((err) => {
+              this.$message.error("添加失败");
+            });
+        } else {
+          console.log("error submit!!");
+          return false;
+        }
+      });
+    },
+    //显示数据
+    showMessageList(id) {
+      console.log(id);
+      showMessage({
+        id: id,
+      })
+        .then((res) => {
+          console.log(res);
+          this.ruleForm = res.data[0];
+          this.ruleForm = {
+            uname: res.data[0].jrname,
+            addressid: res.data[0].jraddressesid,
+            levelid: res.data[0].jrlevel,
+            tel: res.data[0].jrtel,
+          };
+        })
+        .catch((err) => {});
+    },
+  },
+  created() {
+    this.getLocationList();
+    this.getLevelList();
+    console.log(this.$route.query.id);
+    if (this.$route.query.id) {
+      this.isUpdate = true;
+      let _id = this.$route.query.id;
+      this.showMessageList(_id);
+    }
+  },
+};
+</script>
+
+<style scoped>
+.add-message {
+  width: 70%;
+  margin: 100px auto;
+}
+</style>

+ 124 - 0
vue-admin-template-master/src/views/message/messageList.vue

@@ -0,0 +1,124 @@
+/* 
+  信息列表
+  author:zsy
+  date: 2024-1-22
+*/
+<template>
+  <div class="message-list">
+    <el-select v-model="addressValue" placeholder="请选择">
+      <el-option
+        v-for="item in addressList"
+        :key="item.addressid"
+        :label="item.addressname"
+        :value="item.addressid"
+      >
+      </el-option>
+    </el-select>
+    <el-button type="primary" @click="searchMessage">筛选</el-button>
+    <el-button type="info">重置</el-button>
+    <el-table :data="tableData" style="width: 100%">
+      <el-table-column prop="jrid" label="信息ID"> </el-table-column>
+      <el-table-column prop="jraddressesid" label="对应的地址ID">
+      </el-table-column>
+      <el-table-column prop="jrname" label="姓名"> </el-table-column>
+      <el-table-column prop="jrlevel" label="等级ID"> </el-table-column>
+      <el-table-column prop="jrtel" label="电话号码"> </el-table-column>
+      <el-table-column prop="levelname" label="等级名称"> </el-table-column>
+      <el-table-column prop="addressname" label="地址名称"> </el-table-column>
+      <el-table-column fixed="right" label="操作" width="120">
+        <template slot-scope="scope">
+          <el-button
+            @click.native.prevent="updateRow(scope.row)"
+            type="text"
+            size="small"
+          >
+            修改
+          </el-button>
+          <el-button
+            @click.native.prevent="deleteRow(scope.row)"
+            type="text"
+            size="small"
+          >
+            移除
+          </el-button>
+        </template>
+      </el-table-column>
+    </el-table>
+  </div>
+</template>
+
+<script>
+import { getLocation } from "@/api/location";
+import { getMessage ,searchInfo } from "@/api/message";
+export default {
+  data() {
+    return {
+      tableData: [],
+      addressList:[],
+      addressValue: ""
+    };
+  },
+  methods: {
+    getMessageList() {
+      getMessage().then((res) => {
+        this.tableData = res.data;
+      });
+    },
+    //删除按钮
+    deleteRow(row) {},
+    //修改按钮
+    updateRow(row) {
+      console.log(row);
+      this.$router.push({
+        path: "/message/addMessage",
+        query: {
+          id: row.jrid,
+        },
+      });
+    },
+    //获取地址信息
+    getLocationList() {
+      getLocation().then((res) => {
+        console.log(res.data);
+        this.addressList = res.data
+      });
+    },
+    //筛选功能
+    searchMessage(){
+      console.log(this.addressValue)
+
+      let _addressName = ''
+      this.addressList.forEach((val)=>{
+        if(val.addressid == this.addressValue){
+          _addressName = val.addressname
+        }
+      })
+      searchInfo({
+        searchid: this.addressValue
+      }).then((res)=>{
+        console.log(res.data)
+        // this.tableData = res.data
+        let _data = res.data
+        this.tableData = _data.map((val)=>{
+          val.addressname = _addressName
+          val.levelname = '查无此项'
+          return val
+        })
+      }).catch((err)=>{
+        console.log(err)
+      })
+    }
+  },
+  created() {
+    this.getMessageList();
+    this.getLocationList();
+  },
+};
+</script>
+
+<style scoped>
+.message-list {
+  width: 70%;
+  margin: 100px auto;
+}
+</style>

+ 31 - 0
weixin/.eslintrc.js

@@ -0,0 +1,31 @@
+/*
+ * Eslint config file
+ * Documentation: https://eslint.org/docs/user-guide/configuring/
+ * Install the Eslint extension before using this feature.
+ */
+module.exports = {
+  env: {
+    es6: true,
+    browser: true,
+    node: true,
+  },
+  ecmaFeatures: {
+    modules: true,
+  },
+  parserOptions: {
+    ecmaVersion: 2018,
+    sourceType: 'module',
+  },
+  globals: {
+    wx: true,
+    App: true,
+    Page: true,
+    getCurrentPages: true,
+    getApp: true,
+    Component: true,
+    requirePlugin: true,
+    requireMiniProgram: true,
+  },
+  // extends: 'eslint:recommended',
+  rules: {},
+}

+ 19 - 0
weixin/app.js

@@ -0,0 +1,19 @@
+// app.js
+App({
+  onLaunch() {
+    // 展示本地存储能力
+    const logs = wx.getStorageSync('logs') || []
+    logs.unshift(Date.now())
+    wx.setStorageSync('logs', logs)
+
+    // 登录
+    wx.login({
+      success: res => {
+        // 发送 res.code 到后台换取 openId, sessionKey, unionId
+      }
+    })
+  },
+  globalData: {
+    userInfo: null
+  }
+})

+ 35 - 0
weixin/app.json

@@ -0,0 +1,35 @@
+{
+  "pages": [
+    "pages/index/index",
+    "pages/logs/logs",
+    "pages/home/home",
+    "pages/mine/mine"
+  ],
+  "window": {
+    "navigationBarTextStyle": "black",
+    "navigationBarTitleText": "xiaochengxu",
+    "navigationBarBackgroundColor": "#ff0000"
+  },
+  "tabBar": {
+    "list": [
+      {
+        "pagePath": "pages/home/home",
+        "text": "首页",
+        "iconPath": "./pages/image/首页.png",
+        "selectedIconPath": "./pages/image/首页 (1).png"
+      },
+      {
+        "pagePath": "pages/mine/mine",
+        "text": "我的",
+        "iconPath": "./pages/image/我的.png",
+        "selectedIconPath": "./pages/image/我的 (1).png"
+      }
+    ],
+    "color": "#f49329",
+    "selectedColor": "#ff0000"
+  },
+  "style": "v2",
+  "componentFramework": "glass-easel",
+  "sitemapLocation": "sitemap.json",
+  "lazyCodeLoading": "requiredComponents"
+}

+ 10 - 0
weixin/app.wxss

@@ -0,0 +1,10 @@
+/**app.wxss**/
+.container {
+  height: 100%;
+  display: flex;
+  flex-direction: column;
+  align-items: center;
+  justify-content: space-between;
+  padding: 200rpx 0;
+  box-sizing: border-box;
+} 

+ 74 - 0
weixin/pages/home/home.js

@@ -0,0 +1,74 @@
+// pages/home/home.js
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+    msg: 'xixixixi',
+    id: 0,
+    list: ['a','b','c','d'],
+    num: 9,
+    xx: true,
+    obj: {
+      name:'zs',
+      age: 13
+    }
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad(options) {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload() {
+
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh() {
+
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom() {
+
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage() {
+
+  }
+})

+ 3 - 0
weixin/pages/home/home.json

@@ -0,0 +1,3 @@
+{
+  "usingComponents": {}
+}

+ 28 - 0
weixin/pages/home/home.wxml

@@ -0,0 +1,28 @@
+<view>hahaha</view>
+<view>{{msg}}</view>
+
+<view id="item-{{id}}">111</view>
+
+<view wx:for="{{list}}" wx:key="index" wx:for-item="itemName" wx:for-index="idx">
+    {{itemName}} ---------{{idx}}
+</view>
+<view wx:if="{{num>10}}">大于10</view>
+<view wx:elif="{{num<10}}">小于10</view>
+<view wx:else>等于10</view>
+
+
+<block wx:if="{{xx}}">
+    <view>今天天气真冷</view>
+</block>
+
+<view hidden="{{xx}}">显示1</view>
+
+<view data="{{obj}}">
+{{obj.name}} --- {{obj.age}}
+</view>
+
+
+<import src="test.wxml"/>
+<template is="tem" data="{{...obj}}"/>
+
+

+ 1 - 0
weixin/pages/home/home.wxss

@@ -0,0 +1 @@
+/* pages/home/home.wxss */

+ 4 - 0
weixin/pages/home/test.wxml

@@ -0,0 +1,4 @@
+<template name="tem">
+    <view>{{name}}</view>
+    <view>{{age}}</view>
+</template>

二进制
weixin/pages/image/我的 (1).png


二进制
weixin/pages/image/我的.png


二进制
weixin/pages/image/首页 (1).png


二进制
weixin/pages/image/首页.png


+ 49 - 0
weixin/pages/index/index.js

@@ -0,0 +1,49 @@
+// index.js
+const defaultAvatarUrl = 'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0'
+
+Page({
+  data: {
+    motto: 'Hello World',
+    userInfo: {
+      avatarUrl: defaultAvatarUrl,
+      nickName: '',
+    },
+    hasUserInfo: false,
+    canIUseGetUserProfile: wx.canIUse('getUserProfile'),
+    canIUseNicknameComp: wx.canIUse('input.type.nickname'),
+  },
+  bindViewTap() {
+    wx.navigateTo({
+      url: '../logs/logs'
+    })
+  },
+  onChooseAvatar(e) {
+    const { avatarUrl } = e.detail
+    const { nickName } = this.data.userInfo
+    this.setData({
+      "userInfo.avatarUrl": avatarUrl,
+      hasUserInfo: nickName && avatarUrl && avatarUrl !== defaultAvatarUrl,
+    })
+  },
+  onInputChange(e) {
+    const nickName = e.detail.value
+    const { avatarUrl } = this.data.userInfo
+    this.setData({
+      "userInfo.nickName": nickName,
+      hasUserInfo: nickName && avatarUrl && avatarUrl !== defaultAvatarUrl,
+    })
+  },
+  getUserProfile(e) {
+    // 推荐使用wx.getUserProfile获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认,开发者妥善保管用户快速填写的头像昵称,避免重复弹窗
+    wx.getUserProfile({
+      desc: '展示用户信息', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
+      success: (res) => {
+        console.log(res)
+        this.setData({
+          userInfo: res.userInfo,
+          hasUserInfo: true
+        })
+      }
+    })
+  },
+})

+ 4 - 0
weixin/pages/index/index.json

@@ -0,0 +1,4 @@
+{
+  "usingComponents": {
+  }
+}

+ 27 - 0
weixin/pages/index/index.wxml

@@ -0,0 +1,27 @@
+<!--index.wxml-->
+<scroll-view class="scrollarea" scroll-y type="list">
+  <view class="container">
+    <view class="userinfo">
+      <block wx:if="{{canIUseNicknameComp && !hasUserInfo}}">
+        <button class="avatar-wrapper" open-type="chooseAvatar" bind:chooseavatar="onChooseAvatar">
+          <image class="avatar" src="{{userInfo.avatarUrl}}"></image>
+        </button>
+        <view class="nickname-wrapper">
+          <text class="nickname-label">昵称</text>
+          <input type="nickname" class="nickname-input" placeholder="请输入昵称" bind:change="onInputChange" />
+        </view>
+      </block>
+      <block wx:elif="{{!hasUserInfo}}">
+        <button wx:if="{{canIUseGetUserProfile}}" bindtap="getUserProfile"> 获取头像昵称 </button>
+        <view wx:else> 请使用2.10.4及以上版本基础库 </view>
+      </block>
+      <block wx:else>
+        <image bindtap="bindViewTap" class="userinfo-avatar" src="{{userInfo.avatarUrl}}" mode="cover"></image>
+        <text class="userinfo-nickname">{{userInfo.nickName}}</text>
+      </block>
+    </view>
+    <view class="usermotto">
+      <text class="user-motto">{{motto}}</text>
+    </view>
+  </view>
+</scroll-view>

+ 62 - 0
weixin/pages/index/index.wxss

@@ -0,0 +1,62 @@
+/**index.wxss**/
+page {
+  height: 100vh;
+  display: flex;
+  flex-direction: column;
+}
+.scrollarea {
+  flex: 1;
+  overflow-y: hidden;
+}
+
+.userinfo {
+  display: flex;
+  flex-direction: column;
+  align-items: center;
+  color: #aaa;
+  width: 80%;
+}
+
+.userinfo-avatar {
+  overflow: hidden;
+  width: 128rpx;
+  height: 128rpx;
+  margin: 20rpx;
+  border-radius: 50%;
+}
+
+.usermotto {
+  margin-top: 200px;
+}
+
+.avatar-wrapper {
+  padding: 0;
+  width: 56px !important;
+  border-radius: 8px;
+  margin-top: 40px;
+  margin-bottom: 40px;
+}
+
+.avatar {
+  display: block;
+  width: 56px;
+  height: 56px;
+}
+
+.nickname-wrapper {
+  display: flex;
+  width: 100%;
+  padding: 16px;
+  box-sizing: border-box;
+  border-top: .5px solid rgba(0, 0, 0, 0.1);
+  border-bottom: .5px solid rgba(0, 0, 0, 0.1);
+  color: black;
+}
+
+.nickname-label {
+  width: 105px;
+}
+
+.nickname-input {
+  flex: 1;
+}

+ 18 - 0
weixin/pages/logs/logs.js

@@ -0,0 +1,18 @@
+// logs.js
+const util = require('../../utils/util.js')
+
+Page({
+  data: {
+    logs: []
+  },
+  onLoad() {
+    this.setData({
+      logs: (wx.getStorageSync('logs') || []).map(log => {
+        return {
+          date: util.formatTime(new Date(log)),
+          timeStamp: log
+        }
+      })
+    })
+  }
+})

+ 4 - 0
weixin/pages/logs/logs.json

@@ -0,0 +1,4 @@
+{
+  "usingComponents": {
+  }
+}

+ 6 - 0
weixin/pages/logs/logs.wxml

@@ -0,0 +1,6 @@
+<!--logs.wxml-->
+<scroll-view class="scrollarea" scroll-y type="list">
+  <block wx:for="{{logs}}" wx:key="timeStamp" wx:for-item="log">
+    <view class="log-item">{{index + 1}}. {{log.date}}</view>
+  </block>
+</scroll-view>

+ 16 - 0
weixin/pages/logs/logs.wxss

@@ -0,0 +1,16 @@
+page {
+  height: 100vh;
+  display: flex;
+  flex-direction: column;
+}
+.scrollarea {
+  flex: 1;
+  overflow-y: hidden;
+}
+.log-item {
+  margin-top: 20rpx;
+  text-align: center;
+}
+.log-item:last-child {
+  padding-bottom: env(safe-area-inset-bottom);
+}

+ 66 - 0
weixin/pages/mine/mine.js

@@ -0,0 +1,66 @@
+// pages/mine/mine.js
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad(options) {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload() {
+
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh() {
+
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom() {
+
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage() {
+
+  }
+})

+ 3 - 0
weixin/pages/mine/mine.json

@@ -0,0 +1,3 @@
+{
+  "usingComponents": {}
+}

+ 1 - 0
weixin/pages/mine/mine.wxml

@@ -0,0 +1 @@
+<view>这是我的首页</view>

+ 1 - 0
weixin/pages/mine/mine.wxss

@@ -0,0 +1 @@
+/* pages/mine/mine.wxss */

+ 28 - 0
weixin/project.config.json

@@ -0,0 +1,28 @@
+{
+  "compileType": "miniprogram",
+  "libVersion": "trial",
+  "packOptions": {
+    "ignore": [],
+    "include": []
+  },
+  "setting": {
+    "coverView": true,
+    "es6": true,
+    "postcss": true,
+    "minified": true,
+    "enhance": true,
+    "showShadowRootInWxmlPanel": true,
+    "packNpmRelationList": [],
+    "babelSetting": {
+      "ignore": [],
+      "disablePlugins": [],
+      "outputPath": ""
+    }
+  },
+  "condition": {},
+  "editorSetting": {
+    "tabIndent": "auto",
+    "tabSize": 2
+  },
+  "appid": "wx6f4786e3253107ac"
+}

+ 22 - 0
weixin/project.private.config.json

@@ -0,0 +1,22 @@
+{
+  "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
+  "projectname": "weixin",
+  "setting": {
+    "compileHotReLoad": true,
+    "urlCheck": false
+  },
+  "libVersion": "3.3.2",
+  "condition": {
+    "miniprogram": {
+      "list": [
+        {
+          "name": "home",
+          "pathName": "pages/home/home",
+          "query": "",
+          "launchMode": "default",
+          "scene": null
+        }
+      ]
+    }
+  }
+}

+ 7 - 0
weixin/sitemap.json

@@ -0,0 +1,7 @@
+{
+  "desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html",
+  "rules": [{
+  "action": "allow",
+  "page": "*"
+  }]
+}

+ 19 - 0
weixin/utils/util.js

@@ -0,0 +1,19 @@
+const formatTime = date => {
+  const year = date.getFullYear()
+  const month = date.getMonth() + 1
+  const day = date.getDate()
+  const hour = date.getHours()
+  const minute = date.getMinutes()
+  const second = date.getSeconds()
+
+  return `${[year, month, day].map(formatNumber).join('/')} ${[hour, minute, second].map(formatNumber).join(':')}`
+}
+
+const formatNumber = n => {
+  n = n.toString()
+  return n[1] ? n : `0${n}`
+}
+
+module.exports = {
+  formatTime
+}