liyongli 3 anos atrás
pai
commit
94040c8eb5

+ 0 - 25
cloudfunctions/callback/index.js

@@ -1,25 +0,0 @@
-const cloud = require('wx-server-sdk')
-
-cloud.init({
-  // API 调用都保持和云函数当前所在环境一致
-  env: cloud.DYNAMIC_CURRENT_ENV
-})
-
-// 云函数入口函数
-exports.main = async (event, context) => {
-  console.log(event)
-
-  const { OPENID } = cloud.getWXContext()
-
-  const result = await cloud.openapi.customerServiceMessage.send({
-    touser: OPENID,
-    msgtype: 'text',
-    text: {
-      content: `收到:${event.Content}`,
-    }
-  })
-
-  console.log(result)
-
-  return result
-}

+ 0 - 14
cloudfunctions/callback/package.json

@@ -1,14 +0,0 @@
-{
-  "name": "callback",
-  "version": "1.0.0",
-  "description": "",
-  "main": "index.js",
-  "scripts": {
-    "test": "echo \"Error: no test specified\" && exit 1"
-  },
-  "author": "",
-  "license": "ISC",
-  "dependencies": {
-    "wx-server-sdk": "~2.4.0"
-  }
-}

+ 0 - 1
cloudfunctions/callback/config.json → cloudfunctions/cloudbase_auth/config.json

@@ -1,7 +1,6 @@
 {
   "permissions": {
     "openapi": [
-      "customerServiceMessage.send"
     ]
   }
 }

+ 28 - 0
cloudfunctions/cloudbase_auth/index.js

@@ -0,0 +1,28 @@
+const cloud = require('wx-server-sdk')
+cloud.init({
+  env: cloud.DYNAMIC_CURRENT_ENV
+})
+
+// 云函数入口函数
+exports.main = async (event, context) => {
+  const wxContext = cloud.getWXContext()
+
+  console.log(event)
+  console.log(wxContext)
+  // 跨账号调用时,由此拿到来源方小程序/公众号 AppID
+  console.log(wxContext.FROM_APPID)
+  // 跨账号调用时,由此拿到来源方小程序/公众号的用户 OpenID
+  console.log(wxContext.FROM_OPENID)
+  // 跨账号调用、且满足 unionid 获取条件时,由此拿到同主体下的用户 UnionID
+  console.log(wxContext.FROM_UNIONID)
+
+  return {
+    errCode: 0,
+    errMsg: '',
+    auth: JSON.stringify({
+      // 自定义安全规则
+      // 在前端访问资源方数据库、云函数等资源时,资源方可以通过
+      // 安全规则的 `auth.custom` 字段获取此对象的内容做校验
+    }),
+  }
+}

+ 1 - 1
cloudfunctions/echo/package.json → cloudfunctions/cloudbase_auth/package.json

@@ -1,5 +1,5 @@
 {
-  "name": "echo",
+  "name": "cloudbase_auth",
   "version": "1.0.0",
   "description": "",
   "main": "index.js",

+ 0 - 5
cloudfunctions/echo/config.json

@@ -1,5 +0,0 @@
-{
-  "permissions": {
-    "openapi": []
-  }
-}

+ 0 - 8
cloudfunctions/echo/index.js

@@ -1,8 +0,0 @@
-const cloud = require('wx-server-sdk')
-
-exports.main = async (event, context) => {
-  // event.userInfo 是已废弃的保留字段,在此不做展示
-  // 获取 OPENID 等微信上下文请使用 cloud.getWXContext()
-  delete event.userInfo
-  return event
-}

+ 0 - 36
cloudfunctions/login/index.js

@@ -1,36 +0,0 @@
-// 云函数模板
-// 部署:在 cloud-functions/login 文件夹右击选择 “上传并部署”
-
-const cloud = require('wx-server-sdk')
-
-// 初始化 cloud
-cloud.init({
-  // API 调用都保持和云函数当前所在环境一致
-  env: cloud.DYNAMIC_CURRENT_ENV
-})
-
-/**
- * 这个示例将经自动鉴权过的小程序用户 openid 返回给小程序端
- * 
- * event 参数包含小程序端调用传入的 data
- * 
- */
-exports.main = async (event, context) => {
-  console.log(event)
-  console.log(context)
-
-  // 可执行其他自定义逻辑
-  // console.log 的内容可以在云开发云函数调用日志查看
-
-  // 获取 WX Context (微信调用上下文),包括 OPENID、APPID、及 UNIONID(需满足 UNIONID 获取条件)等信息
-  const wxContext = cloud.getWXContext()
-
-  return {
-    event,
-    openid: wxContext.OPENID,
-    appid: wxContext.APPID,
-    unionid: wxContext.UNIONID,
-    env: wxContext.ENV,
-  }
-}
-

+ 48 - 0
cloudfunctions/server/auto/utils.js

@@ -0,0 +1,48 @@
+const cloudbase = require("@cloudbase/node-sdk");
+
+async function checkAuth() {
+  // 获取用户信息
+  // 在云函数中获取用户身份信息
+  const app = cloudbase.init();
+  const { TCB_UUID } = cloudbase.getCloudbaseContext();
+  let { userInfo } = await app.auth().getEndUserInfo(TCB_UUID);
+
+  // 未登录用户
+  if (!userInfo.username && !userInfo.openId) {
+    return {
+      msg: "未登录用户!",
+      result: false
+    }
+  }
+
+  // 校验用户是否为 CMS 的用户
+  // 腾讯云 CMS 用户数据集合为 tcb-ext-cms-users
+  // 微信 CMS 用户数据集合为 wx-ext-cms-users
+  const {
+    data: [userRecord]
+  } = await app
+    .database()
+    .collection("tcb-ext-cms-users")
+    .where({
+      username: userInfo.username
+    })
+    .get();
+
+  // 用户信息不存在
+  if (!userRecord) {
+    return {
+      msg: "用户不存在,请确认登录信息!",
+      result: false
+    }
+  }
+
+  // 校验通过
+  return {
+    msg: "",
+    result: true
+  }
+}
+
+exports.config = {
+  checkAuth
+}

+ 3 - 2
cloudfunctions/login/config.json → cloudfunctions/server/config.json

@@ -1,5 +1,6 @@
 {
   "permissions": {
-    "openapi": []
+    "openapi": [
+    ]
   }
-}
+}

+ 26 - 0
cloudfunctions/server/index.js

@@ -0,0 +1,26 @@
+// 云函数入口文件
+const cloud = require('wx-server-sdk')
+
+const utils = require("./auto/utils")
+
+cloud.init()
+
+// 云函数入口函数
+exports.main = async (event, context) => {
+  let result = await utils.checkAuth();
+  if(!result.result) return {
+    msg: result.msg
+  }
+  console.log(event)
+  switch (event.action) {
+    case 'img': {
+      return upImage(event)
+    }
+    case 'video': {
+      return video(event)
+    }
+    default: {
+      return {}
+    }
+  }
+}

+ 25 - 25
cloudfunctions/login/package-lock.json → cloudfunctions/server/package-lock.json

@@ -1,5 +1,5 @@
 {
-  "name": "login",
+  "name": "server",
   "version": "1.0.0",
   "lockfileVersion": 2,
   "requires": true,
@@ -24,7 +24,7 @@
     },
     "node_modules/@cloudbase/node-sdk": {
       "version": "2.4.7",
-      "resolved": "https://registry.nlark.com/@cloudbase/node-sdk/download/@cloudbase/node-sdk-2.4.7.tgz",
+      "resolved": "https://registry.nlark.com/@cloudbase/node-sdk/download/@cloudbase/node-sdk-2.4.7.tgz?cache=0&sync_timestamp=1622552558340&other_urls=https%3A%2F%2Fregistry.nlark.com%2F%40cloudbase%2Fnode-sdk%2Fdownload%2F%40cloudbase%2Fnode-sdk-2.4.7.tgz",
       "integrity": "sha1-IGpM5swxN89GqTkso3IRe4JD1rM=",
       "dependencies": {
         "@cloudbase/database": "1.2.2",
@@ -121,7 +121,7 @@
     },
     "node_modules/@types/node": {
       "version": "10.17.60",
-      "resolved": "https://registry.nlark.com/@types/node/download/@types/node-10.17.60.tgz?cache=0&sync_timestamp=1621901524629&other_urls=https%3A%2F%2Fregistry.nlark.com%2F%40types%2Fnode%2Fdownload%2F%40types%2Fnode-10.17.60.tgz",
+      "resolved": "https://registry.nlark.com/@types/node/download/@types/node-10.17.60.tgz?cache=0&sync_timestamp=1622824508013&other_urls=https%3A%2F%2Fregistry.nlark.com%2F%40types%2Fnode%2Fdownload%2F%40types%2Fnode-10.17.60.tgz",
       "integrity": "sha1-NfPWIT2u2V2n8Pc+dbzGmA6QWXs="
     },
     "node_modules/@types/retry": {
@@ -144,7 +144,7 @@
     },
     "node_modules/ajv": {
       "version": "6.12.6",
-      "resolved": "https://registry.nlark.com/ajv/download/ajv-6.12.6.tgz?cache=0&sync_timestamp=1621517642931&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fajv%2Fdownload%2Fajv-6.12.6.tgz",
+      "resolved": "https://registry.nlark.com/ajv/download/ajv-6.12.6.tgz",
       "integrity": "sha1-uvWmLoArB9l3A0WG+MO69a3ybfQ=",
       "dependencies": {
         "fast-deep-equal": "^3.1.1",
@@ -650,19 +650,19 @@
       "integrity": "sha1-LrLjfqm2fEiR9oShOUeZr0hM96I="
     },
     "node_modules/mime-db": {
-      "version": "1.47.0",
-      "resolved": "https://registry.nlark.com/mime-db/download/mime-db-1.47.0.tgz",
-      "integrity": "sha1-jLMT5Zll08Bc+/iYkVomevRqM1w=",
+      "version": "1.48.0",
+      "resolved": "https://registry.nlark.com/mime-db/download/mime-db-1.48.0.tgz?cache=0&sync_timestamp=1622433567590&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fmime-db%2Fdownload%2Fmime-db-1.48.0.tgz",
+      "integrity": "sha1-41sxBF3X6to6qtU37YijOvvvLR0=",
       "engines": {
         "node": ">= 0.6"
       }
     },
     "node_modules/mime-types": {
-      "version": "2.1.30",
-      "resolved": "https://registry.nlark.com/mime-types/download/mime-types-2.1.30.tgz",
-      "integrity": "sha1-bnvotMR5gl+F7WMmaV23P5MF1i0=",
+      "version": "2.1.31",
+      "resolved": "https://registry.nlark.com/mime-types/download/mime-types-2.1.31.tgz?cache=0&sync_timestamp=1622569304088&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fmime-types%2Fdownload%2Fmime-types-2.1.31.tgz",
+      "integrity": "sha1-oA12t0MXxh+cLbIhi46fjpxcnms=",
       "dependencies": {
-        "mime-db": "1.47.0"
+        "mime-db": "1.48.0"
       },
       "engines": {
         "node": ">= 0.6"
@@ -968,7 +968,7 @@
     },
     "node_modules/typescript": {
       "version": "4.3.2",
-      "resolved": "https://registry.nlark.com/typescript/download/typescript-4.3.2.tgz?cache=0&sync_timestamp=1622101007156&other_urls=https%3A%2F%2Fregistry.nlark.com%2Ftypescript%2Fdownload%2Ftypescript-4.3.2.tgz",
+      "resolved": "https://registry.nlark.com/typescript/download/typescript-4.3.2.tgz",
       "integrity": "sha1-OZqxiqxFgC1vJJjeUFT8u+cWqAU=",
       "peer": true,
       "bin": {
@@ -1003,7 +1003,7 @@
     },
     "node_modules/uuid": {
       "version": "3.4.0",
-      "resolved": "https://registry.npm.taobao.org/uuid/download/uuid-3.4.0.tgz?cache=0&sync_timestamp=1607460077975&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fuuid%2Fdownload%2Fuuid-3.4.0.tgz",
+      "resolved": "https://registry.nlark.com/uuid/download/uuid-3.4.0.tgz?cache=0&sync_timestamp=1622213086354&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fuuid%2Fdownload%2Fuuid-3.4.0.tgz",
       "integrity": "sha1-sj5DWK+oogL+ehAK8fX4g/AgB+4=",
       "bin": {
         "uuid": "bin/uuid"
@@ -1076,7 +1076,7 @@
     },
     "@cloudbase/node-sdk": {
       "version": "2.4.7",
-      "resolved": "https://registry.nlark.com/@cloudbase/node-sdk/download/@cloudbase/node-sdk-2.4.7.tgz",
+      "resolved": "https://registry.nlark.com/@cloudbase/node-sdk/download/@cloudbase/node-sdk-2.4.7.tgz?cache=0&sync_timestamp=1622552558340&other_urls=https%3A%2F%2Fregistry.nlark.com%2F%40cloudbase%2Fnode-sdk%2Fdownload%2F%40cloudbase%2Fnode-sdk-2.4.7.tgz",
       "integrity": "sha1-IGpM5swxN89GqTkso3IRe4JD1rM=",
       "requires": {
         "@cloudbase/database": "1.2.2",
@@ -1170,7 +1170,7 @@
     },
     "@types/node": {
       "version": "10.17.60",
-      "resolved": "https://registry.nlark.com/@types/node/download/@types/node-10.17.60.tgz?cache=0&sync_timestamp=1621901524629&other_urls=https%3A%2F%2Fregistry.nlark.com%2F%40types%2Fnode%2Fdownload%2F%40types%2Fnode-10.17.60.tgz",
+      "resolved": "https://registry.nlark.com/@types/node/download/@types/node-10.17.60.tgz?cache=0&sync_timestamp=1622824508013&other_urls=https%3A%2F%2Fregistry.nlark.com%2F%40types%2Fnode%2Fdownload%2F%40types%2Fnode-10.17.60.tgz",
       "integrity": "sha1-NfPWIT2u2V2n8Pc+dbzGmA6QWXs="
     },
     "@types/retry": {
@@ -1190,7 +1190,7 @@
     },
     "ajv": {
       "version": "6.12.6",
-      "resolved": "https://registry.nlark.com/ajv/download/ajv-6.12.6.tgz?cache=0&sync_timestamp=1621517642931&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fajv%2Fdownload%2Fajv-6.12.6.tgz",
+      "resolved": "https://registry.nlark.com/ajv/download/ajv-6.12.6.tgz",
       "integrity": "sha1-uvWmLoArB9l3A0WG+MO69a3ybfQ=",
       "requires": {
         "fast-deep-equal": "^3.1.1",
@@ -1627,16 +1627,16 @@
       "integrity": "sha1-LrLjfqm2fEiR9oShOUeZr0hM96I="
     },
     "mime-db": {
-      "version": "1.47.0",
-      "resolved": "https://registry.nlark.com/mime-db/download/mime-db-1.47.0.tgz",
-      "integrity": "sha1-jLMT5Zll08Bc+/iYkVomevRqM1w="
+      "version": "1.48.0",
+      "resolved": "https://registry.nlark.com/mime-db/download/mime-db-1.48.0.tgz?cache=0&sync_timestamp=1622433567590&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fmime-db%2Fdownload%2Fmime-db-1.48.0.tgz",
+      "integrity": "sha1-41sxBF3X6to6qtU37YijOvvvLR0="
     },
     "mime-types": {
-      "version": "2.1.30",
-      "resolved": "https://registry.nlark.com/mime-types/download/mime-types-2.1.30.tgz",
-      "integrity": "sha1-bnvotMR5gl+F7WMmaV23P5MF1i0=",
+      "version": "2.1.31",
+      "resolved": "https://registry.nlark.com/mime-types/download/mime-types-2.1.31.tgz?cache=0&sync_timestamp=1622569304088&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fmime-types%2Fdownload%2Fmime-types-2.1.31.tgz",
+      "integrity": "sha1-oA12t0MXxh+cLbIhi46fjpxcnms=",
       "requires": {
-        "mime-db": "1.47.0"
+        "mime-db": "1.48.0"
       }
     },
     "ms": {
@@ -1868,7 +1868,7 @@
     },
     "typescript": {
       "version": "4.3.2",
-      "resolved": "https://registry.nlark.com/typescript/download/typescript-4.3.2.tgz?cache=0&sync_timestamp=1622101007156&other_urls=https%3A%2F%2Fregistry.nlark.com%2Ftypescript%2Fdownload%2Ftypescript-4.3.2.tgz",
+      "resolved": "https://registry.nlark.com/typescript/download/typescript-4.3.2.tgz",
       "integrity": "sha1-OZqxiqxFgC1vJJjeUFT8u+cWqAU=",
       "peer": true
     },
@@ -1898,7 +1898,7 @@
     },
     "uuid": {
       "version": "3.4.0",
-      "resolved": "https://registry.npm.taobao.org/uuid/download/uuid-3.4.0.tgz?cache=0&sync_timestamp=1607460077975&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fuuid%2Fdownload%2Fuuid-3.4.0.tgz",
+      "resolved": "https://registry.nlark.com/uuid/download/uuid-3.4.0.tgz?cache=0&sync_timestamp=1622213086354&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fuuid%2Fdownload%2Fuuid-3.4.0.tgz",
       "integrity": "sha1-sj5DWK+oogL+ehAK8fX4g/AgB+4="
     },
     "verror": {

+ 1 - 1
cloudfunctions/login/package.json → cloudfunctions/server/package.json

@@ -1,5 +1,5 @@
 {
-  "name": "login",
+  "name": "server",
   "version": "1.0.0",
   "description": "",
   "main": "index.js",

+ 1 - 1
miniprogram/app.json

@@ -12,7 +12,7 @@
     "backgroundColor": "#F6F6F6",
     "backgroundTextStyle": "light",
     "navigationBarBackgroundColor": "#F6F6F6",
-    "navigationBarTitleText": "寻红色记忆",
+    "navigationBarTitleText": "寻红色记忆",
     "navigationBarTextStyle": "black"
   },
   "requiredBackgroundModes":["audio"],

Diferenças do arquivo suprimidas por serem muito extensas
+ 0 - 33
miniprogram/ec-canvas/echarts.js


BIN
miniprogram/images/5.png


+ 9 - 9
miniprogram/pages/home/index.wxml

@@ -25,14 +25,6 @@
         </view>
       </view>
     </view>
-    <view class="icon_item_cell">
-      <view class="icon_content" data-title="疫情防控" data-id="cbddf0af60b042750c3ebf6b09f3e165" bindtap="toDetail">
-        <image class="img" src="../../images/2.png"></image>
-        <view class="icon_title">
-          疫情防控
-        </view>
-      </view>
-    </view>
     <view class="icon_item_cell">
       <view class="icon_content" data-title="精彩瞬间" data-type="img" bindtap="toMarvellous">
         <image class="img" src="../../images/3.png"></image>
@@ -53,7 +45,15 @@
       <view class="icon_content" bindtap="toRuins">
         <image class="img" src="../../images/5.png"></image>
         <view class="icon_title">
-          红色遗址会发声
+          延安印迹
+        </view>
+      </view>
+    </view>
+    <view class="icon_item_cell">
+      <view class="icon_content" data-title="疫情防控" data-id="cbddf0af60b042750c3ebf6b09f3e165" bindtap="toDetail">
+        <image class="img" src="../../images/2.png"></image>
+        <view class="icon_title">
+          疫情防控
         </view>
       </view>
     </view>

+ 17 - 16
miniprogram/pages/marvellous/index.js

@@ -21,7 +21,7 @@ Page({
     wx.setNavigationBarTitle({
       title: options.title || "精彩瞬间"
     })
-    
+
     const db = wx.cloud.database();
     const _ = db.command;
     const $ = db.command.aggregate
@@ -36,13 +36,14 @@ Page({
       title: '暂无数据',
       icon: "none"
     })
-    for (let i = 0; i < list.data.length; i++) {
-      const v = list.data[i];
+    let li = list.data || [];
+    for (let i = 0; i < li.length; i++) {
+      const v = li[i];
+      console.log(v)
       v.index = i;
-      pageList[v.creat_time] ? pageList[v.creat_time].list.push(v) : pageList[v.creat_time] = { list: [v], time: this.format(v.creat_time) };
+      pageList[v.create_time] ? pageList[v.create_time].list.push(v) : pageList[v.create_time] = { list: [v], time: this.format(v.create_time) };
       this.imgList.push(v.url);
     }
-    console.log(pageList)
     this.setData({
       pageList: pageList,
       pageType: options.type || "img"
@@ -99,15 +100,15 @@ Page({
   },
   showImg(e) {
     if (this.data.showSelect) return this.btnSelect(e);
-    if(this.data.pageType === "video") return this.showVideo(e);
-    if(this.data.pageType === "img") return this.showImage(e);
+    if (this.data.pageType === "video") return this.showVideo(e);
+    if (this.data.pageType === "img") return this.showImage(e);
   },
-  showVideo:function(e){
+  showVideo: function (e) {
     this.setData({
       showVideo: this.imgList[e.currentTarget.dataset.index]
     })
   },
-  showImage:function(e){
+  showImage: function (e) {
     wx.previewImage({
       urls: this.imgList,
       current: this.imgList[e.currentTarget.dataset.index],
@@ -155,7 +156,7 @@ Page({
     })
   },
   format: function (res) {
-    if(!res) return ""
+    if (!res) return ""
     let T = new Date(res || 0);
     let year = T.getFullYear();
     let month = T.getMonth() + 1;
@@ -171,11 +172,11 @@ Page({
     let _this = this;
     // 权限判断
     wx.getSetting({
-      success: function(res){
+      success: function (res) {
         if (!res['scope.writePhotosAlbum']) {
           wx.authorize({
             scope: 'scope.writePhotosAlbum',
-            success: function(res){
+            success: function (res) {
               wx.showLoading();
               let keys = Object.keys(_this.data.select);
               _this.downCount = keys.length - 1;
@@ -185,7 +186,7 @@ Page({
                 _this.downFile(v);
               }
             },
-            fail:function(err){
+            fail: function (err) {
               wx.showToast({
                 title: '未获取权限',
                 icon: "none"
@@ -203,7 +204,7 @@ Page({
           _this.downFile(v);
         }
       },
-      fail:function(err){
+      fail: function (err) {
         wx.showToast({
           title: '未获取权限',
           icon: "none"
@@ -271,12 +272,12 @@ Page({
       wx.hideLoading();
     }
   },
-  closeVideo: function(){
+  closeVideo: function () {
     this.setData({
       showVideo: ""
     })
   },
-  closeAnvido:function(){
+  closeAnvido: function () {
     this.setData({
       showAnVideo: false
     })

+ 4 - 10
miniprogram/pages/ruins/index.js

@@ -18,7 +18,8 @@ Page({
    * 生命周期函数--监听页面加载
    */
   onLoad: function (options) {
-
+    const db = wx.cloud.database()
+    const $ = db.command.aggregate;
   },
 
   /**
@@ -87,17 +88,12 @@ Page({
     let list = await db.collection('map_json').where({
       region: _.eq("china")
     }).get();
+    console.log(JSON.stringify(list.data[0].geoJson))
     echarts.registerMap('CN', list.data[0].geoJson);
     var option = {
       tooltip: {
         show: false
       },
-      "dataZoom-inside": {
-        type: "inside"
-      },
-      scaleLimit: {
-        min: 1.25  //缩放最小大小
-      },
       geo: {
         map: "CN",
         roam: true,//改成true也完全没效果
@@ -128,9 +124,7 @@ Page({
           },
         },
       },
-      series: [
-
-      ]
+      series: []
     };
     this.chart.setOption(option);
     this.chart.on("click", (params) => {

Alguns arquivos não foram mostrados porque muitos arquivos mudaram nesse diff