Browse Source

first commit

xing.li 3 years ago
commit
80ac26be65

+ 19 - 0
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
+  }
+})

+ 16 - 0
app.json

@@ -0,0 +1,16 @@
+{
+  "pages":[
+    "pages/activityList/activityList",
+    "pages/index/index",
+    "pages/logs/logs"
+    
+  ],
+  "window":{
+    "backgroundTextStyle":"light",
+    "navigationBarBackgroundColor": "#fff",
+    "navigationBarTitleText": "Weixin",
+    "navigationBarTextStyle":"black"
+  },
+  "style": "v2",
+  "sitemapLocation": "sitemap.json"
+}

+ 23 - 0
app.wxss

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

BIN
images/xjq.png


BIN
images/zkq.png


+ 66 - 0
pages/activityList/activityList.js

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

+ 9 - 0
pages/activityList/activityList.json

@@ -0,0 +1,9 @@
+{
+  "usingComponents": {},
+  "navigationBarBackgroundColor": "#fff",
+  "navigationBarTextStyle": "black",
+  "navigationBarTitleText": "领取活动",
+  "backgroundColor": "#fff",
+  "backgroundTextStyle": "light"
+ 
+}

+ 54 - 0
pages/activityList/activityList.wxml

@@ -0,0 +1,54 @@
+<view class="list">
+  <view class="activity flex-column">
+    <view class="top flex-row">
+      <image class="top-left" src="https://dy.shpr.top/recruit/home_page.png"></image>
+      <view class="top-right flex-column">
+        <view class="top-right-top">长阳路外卖店券</view>
+        <view class="top-right-bottom flex-row">
+          <view class="top-right-bottom-view  flex-row">
+            <image class="trbv-img" src="/images/xjq.png"></image>
+            <view class="trbv-name">折扣券(3)</view>
+          </view>
+          <view class="top-right-bottom-view  flex-row">
+            <image class="trbv-img" src="/images/zkq.png"></image>
+            <view class="trbv-name">折扣券(3)</view>
+          </view>
+        </view>
+        <view></view>
+      </view>
+    </view>
+    <view class="middle">
+      <view class="middle-line"></view>
+    </view>
+    <view class="bottom flex-row">
+      <view class="bottom-left">2021.09.07-2022.12.15</view>
+      <view class="bottom-right">立即分享</view>
+    </view>
+  </view>
+  <view class="activity flex-column">
+    <view class="top flex-row">
+      <image class="top-left" src="https://dy.shpr.top/recruit/home_page.png"></image>
+      <view class="top-right flex-column">
+        <view class="top-right-top">长阳路外卖店券</view>
+        <view class="top-right-bottom flex-row">
+          <view class="top-right-bottom-view  flex-row">
+            <image class="trbv-img" src="/images/xjq.png"></image>
+            <view class="trbv-name">折扣券(3)</view>
+          </view>
+          <view class="top-right-bottom-view  flex-row">
+            <image class="trbv-img" src="/images/zkq.png"></image>
+            <view class="trbv-name">折扣券(3)</view>
+          </view>
+        </view>
+        <view></view>
+      </view>
+    </view>
+    <view class="middle">
+      <view class="middle-line"></view>
+    </view>
+    <view class="bottom flex-row">
+      <view class="bottom-left">2021.09.07-2022.12.15</view>
+      <view class="bottom-right">立即分享</view>
+    </view>
+  </view>
+</view>

+ 116 - 0
pages/activityList/activityList.wxss

@@ -0,0 +1,116 @@
+/* pages/activityList/activityList.wxss */
+
+Page {
+  width: 100%;
+  height: 100%;
+  /* background-color: #F7F7F7; */
+}
+
+.list {
+  width: 100%;
+  padding-left: 17px;
+  padding-top: 25px;
+}
+
+.activity {
+  width: 341px;
+  height: 136px;
+  background-color: #FFEFF1;
+  border-radius: 5px;
+  margin-bottom: 12px;
+}
+
+.top {
+  width: 100%;
+  height: 70px;
+  margin-top: 16px;
+}
+
+.top-left {
+  width: 82px;
+  height: 69px;
+  border-radius: 5px;
+  margin-left: 27px;
+}
+
+.top-right {
+  width: 200px;
+  margin-left: 24px;
+}
+
+.top-right-top {
+  width: 200px;
+  height: 20px;
+  line-height: 20px;
+  font-size: 15px;
+  font-weight: bold;
+  color: #BF2637;
+  overflow: hidden;
+  text-overflow: ellipsis;
+  white-space: nowrap;
+}
+
+.top-right-bottom {
+  width: 200px;
+  height: 18px;
+  margin-top: 13px;
+  font-size: 9px;
+  font-weight: 400;
+  color: #BF2637;
+}
+
+.top-right-bottom-view {
+  width: 84px;
+  height: 18px;
+  background-color: #fff;
+  border-radius: 3px;
+  margin-right: 11px;
+}
+
+.trbv-img {
+  width: 12px;
+  height: 12px;
+  margin-left: 4px;
+}
+
+.trbv-name {
+  width: 55px;
+  height: 12px;
+  margin-left: 8px;
+}
+
+.middle-line {
+  width: 295px;
+  height: 1px;
+  border-bottom: 1px dashed #BF2637;
+}
+.middle{
+  margin: 0 auto;
+  margin-top: 9px;
+}
+.bottom{
+  width: 100%;
+  height: 20px;
+  margin-top: 9px;
+  justify-content: space-between!important;
+}
+.bottom-left{
+  width: 150px;
+height: 20px;
+line-height: 20px;
+font-size: 10px;
+font-weight: 400;
+color: #BF2637;
+margin-left: 34px;
+}
+.bottom-right{
+  width: 80px;
+  height: 20px;
+  background-color: #BF2637;
+  color: #fff;
+  font-size:10px ;
+  text-align: center;
+  line-height: 20px;
+  border-radius: 10px;
+  margin-right: 25px;
+}

+ 48 - 0
pages/index/index.js

@@ -0,0 +1,48 @@
+// index.js
+// 获取应用实例
+const app = getApp()
+
+Page({
+  data: {
+    motto: 'Hello World',
+    userInfo: {},
+    hasUserInfo: false,
+    canIUse: wx.canIUse('button.open-type.getUserInfo'),
+    canIUseGetUserProfile: false,
+    canIUseOpenData: wx.canIUse('open-data.type.userAvatarUrl') && wx.canIUse('open-data.type.userNickName') // 如需尝试获取用户信息可改为false
+  },
+  // 事件处理函数
+  bindViewTap() {
+    wx.navigateTo({
+      url: '../logs/logs'
+    })
+  },
+  onLoad() {
+    if (wx.getUserProfile) {
+      this.setData({
+        canIUseGetUserProfile: true
+      })
+    }
+  },
+  getUserProfile(e) {
+    // 推荐使用wx.getUserProfile获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认,开发者妥善保管用户快速填写的头像昵称,避免重复弹窗
+    wx.getUserProfile({
+      desc: '展示用户信息', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
+      success: (res) => {
+        console.log(res)
+        this.setData({
+          userInfo: res.userInfo,
+          hasUserInfo: true
+        })
+      }
+    })
+  },
+  getUserInfo(e) {
+    // 不推荐使用getUserInfo获取用户信息,预计自2021年4月13日起,getUserInfo将不再弹出弹窗,并直接返回匿名的用户个人信息
+    console.log(e)
+    this.setData({
+      userInfo: e.detail.userInfo,
+      hasUserInfo: true
+    })
+  }
+})

+ 3 - 0
pages/index/index.json

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

+ 23 - 0
pages/index/index.wxml

@@ -0,0 +1,23 @@
+<!--index.wxml-->
+<view class="container">
+  <view class="userinfo">
+    <block wx:if="{{canIUseOpenData}}">
+      <view class="userinfo-avatar" bindtap="bindViewTap">
+        <open-data type="userAvatarUrl"></open-data>
+      </view>
+      <open-data type="userNickName"></open-data>
+    </block>
+    <block wx:elif="{{!hasUserInfo}}">
+      <button wx:if="{{canIUseGetUserProfile}}" bindtap="getUserProfile"> 获取头像昵称 </button>
+      <button wx:elif="{{canIUse}}" open-type="getUserInfo" bindgetuserinfo="getUserInfo"> 获取头像昵称 </button>
+      <view wx:else> 请使用1.4.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>

+ 19 - 0
pages/index/index.wxss

@@ -0,0 +1,19 @@
+/**index.wxss**/
+.userinfo {
+  display: flex;
+  flex-direction: column;
+  align-items: center;
+  color: #aaa;
+}
+
+.userinfo-avatar {
+  overflow: hidden;
+  width: 128rpx;
+  height: 128rpx;
+  margin: 20rpx;
+  border-radius: 50%;
+}
+
+.usermotto {
+  margin-top: 200px;
+}

+ 18 - 0
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
pages/logs/logs.json

@@ -0,0 +1,4 @@
+{
+  "navigationBarTitleText": "查看启动日志",
+  "usingComponents": {}
+}

+ 6 - 0
pages/logs/logs.wxml

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

+ 8 - 0
pages/logs/logs.wxss

@@ -0,0 +1,8 @@
+.log-list {
+  display: flex;
+  flex-direction: column;
+  padding: 40rpx;
+}
+.log-item {
+  margin: 10rpx;
+}

+ 74 - 0
project.config.json

@@ -0,0 +1,74 @@
+{
+  "description": "项目配置文件",
+  "packOptions": {
+    "ignore": []
+  },
+  "setting": {
+    "urlCheck": false,
+    "es6": true,
+    "enhance": true,
+    "postcss": false,
+    "preloadBackgroundData": false,
+    "minified": false,
+    "newFeature": false,
+    "coverView": true,
+    "nodeModules": true,
+    "autoAudits": false,
+    "showShadowRootInWxmlPanel": true,
+    "scopeDataCheck": false,
+    "uglifyFileName": false,
+    "checkInvalidKey": true,
+    "checkSiteMap": true,
+    "uploadWithSourceMap": true,
+    "compileHotReLoad": false,
+    "lazyloadPlaceholderEnable": false,
+    "useMultiFrameRuntime": true,
+    "useApiHook": true,
+    "useApiHostProcess": false,
+    "babelSetting": {
+      "ignore": [],
+      "disablePlugins": [],
+      "outputPath": ""
+    },
+    "enableEngineNative": false,
+    "useIsolateContext": true,
+    "userConfirmedBundleSwitch": false,
+    "packNpmManually": false,
+    "packNpmRelationList": [],
+    "minifyWXSS": false,
+    "showES6CompileOption": false
+  },
+  "compileType": "miniprogram",
+  "libVersion": "2.19.4",
+  "appid": "wxcc1cdb8babd3f62c",
+  "projectname": "%E9%A3%9E%E7%A0%81",
+  "debugOptions": {
+    "hidedInDevtools": []
+  },
+  "scripts": {},
+  "staticServerOptions": {
+    "baseURL": "",
+    "servePath": ""
+  },
+  "isGameTourist": false,
+  "condition": {
+    "search": {
+      "list": []
+    },
+    "conversation": {
+      "list": []
+    },
+    "game": {
+      "list": []
+    },
+    "plugin": {
+      "list": []
+    },
+    "gamePlugin": {
+      "list": []
+    },
+    "miniprogram": {
+      "list": []
+    }
+  }
+}

+ 7 - 0
sitemap.json

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

+ 19 - 0
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
+}