Silent há 6 anos atrás
pai
commit
04af6f04e8
3 ficheiros alterados com 44 adições e 33 exclusões
  1. 30 0
      database/seeds/ContentSeeder.php
  2. 13 33
      wechat/app.js
  3. 1 0
      wechat/pages/login/index.js

+ 30 - 0
database/seeds/ContentSeeder.php

xqd
@@ -0,0 +1,30 @@
+<?php
+
+use Illuminate\Database\Seeder;
+
+class ContentSeeder extends Seeder
+{
+    /**
+     * Run the database seeds.
+     *
+     * @return void
+     */
+    public function run()
+    {
+        $values = [1, 3, 4];
+        foreach ($values as $value) {
+            $item = \App\Models\Content::where('type', $value)->first();
+            if(!empty($item)) {
+                for ($i = 0; $i < 20; ++$i) {
+                    \App\Models\Content::create([
+                        'type' => $value,
+                        'title' => $item->title,
+                        'pic_url' => $item->pic_url,
+                        'content' => $item->content,
+                        'sort' => $item->sort
+                    ]);
+                }
+            }
+        }
+    }
+}

+ 13 - 33
wechat/app.js

xqd xqd
@@ -6,28 +6,16 @@ App({
     var logs = wx.getStorageSync('logs') || []
     logs.unshift(Date.now())
     wx.setStorageSync('logs', logs)
-
+    var that = this;
     wx.checkSession({
       success: function() {
-
+        var we_chat_user_id = wx.getStorageSync('we_chat_user_id')
+        if(!we_chat_user_id) {
+          that.login()
+        }
       },
       fail: function() {
-        wx.login({
-          success: res => {
-            wx.request({
-              url: api.loginUrl,
-              method: 'GET',
-              data: {
-                code: res.code
-              },
-              success: res => {
-                if(res.data.status == 'success') {
-                  wx.setStorageSync('we_chat_user_id', res.data.id);
-                }
-              }
-            })
-          }
-        })
+        that.login()
       }
     })
   },
@@ -55,27 +43,19 @@ App({
   login: function(info) {
     wx.login({
       success: res => {
-        console.log(info, res)
         wx.request({
           url: api.loginUrl,
-          method: 'POST',
+          method: 'GET',
           data: {
-            code: res.code,
-            iv: info.iv,
-            encryptedData: info.encryptedData
+            code: res.code
           },
-          success: info => {
-            console.log(info);
-            if (info.data.status == 'success') {
-              wx.setStorageSync('pt_student', info.data.data);
-              getApp().globalData.ptStudent = info.data.data;
-              wx.switchTab({
-                url: '/pages/index/index',
-              })
+          success: res => {
+            if (res.data.status == 'success') {
+              wx.setStorageSync('we_chat_user_id', res.data.id);
             }
           }
-        });
+        })
       }
-    });
+    })
   }
 })

+ 1 - 0
wechat/pages/login/index.js

xqd
@@ -27,6 +27,7 @@ Page({
       wx.showLoading({
         title: '登录中',
       })
+      console.log(wx.getStorageSync('we_chat_user_id'))
       wx.request({
         url: api.updateUserInfoUrl,
         method: 'POST',