Skip to content
This repository has been archived by the owner on Jun 1, 2023. It is now read-only.

Commit

Permalink
feat: index 40% finished
Browse files Browse the repository at this point in the history
index 40% finished
  • Loading branch information
buyaobishige committed Mar 20, 2021
1 parent 1a9f471 commit 7be636b
Show file tree
Hide file tree
Showing 15 changed files with 162 additions and 19 deletions.
15 changes: 15 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "pwa-chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://localhost:8080",
"webRoot": "${workspaceFolder}"
}
]
}
7 changes: 4 additions & 3 deletions app/app.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"entryPagePath": "pages/tab/index/index",
"pages": ["pages/main/main", "pages/tab/index/index" ],
"pages": ["pages/main/main", "pages/tab/index/index"],
"window": {
"navigationBarBackgroundColor": "@navBgColor",
"navigationBarTextStyle": "@navTextStyle",
Expand All @@ -9,7 +9,8 @@
"backgroundTextStyle": "@bgTxtStyle",
"backgroundColorTop": "@bgColorTop",
"backgroundColorBottom": "@bgColorBottom",
"pageOrientation": "portrait"
"pageOrientation": "portrait",
"navigationStyle": "custom"
},
"networkTimeout": {
"request": 5000,
Expand All @@ -31,4 +32,4 @@
"singlePage": {
"navigationBarFit": "float"
}
}
}
1 change: 1 addition & 0 deletions app/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ App({
globalData: ({
version,
openid: "",
foodlist: "",
} as unknown) as GlobalData,

onLaunch() {
Expand Down
2 changes: 1 addition & 1 deletion app/pages/tab/index/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
box-sizing: content-box;

width: 100%;
padding-top: 20px;
padding-top: 45px;

background-color: var(--accent-color);
color: #000;
Expand Down
18 changes: 15 additions & 3 deletions app/pages/tab/index/index.wxml
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
<wxs src="./index.wxs" module="content" />
<!-- 导航栏 -->
<view class="navbar placeholder" style="margin-top: {{statusBarHeight}}px;">
<view class="navbar-wrapper" style="padding-top: {{statusBarHeight}}px;">
<view
class="navbar placeholder"
style="margin-top: {{content.statusBarHeight}}px;"
>
<view
class="navbar-wrapper"
style="padding-top: {{content.statusBarHeight}}px;"
>
<view class="title">
<view class="toggle" catch:tap="{{content.onToggle}}">
<text>分类</text>
Expand Down Expand Up @@ -34,7 +40,11 @@
</view>
</view>
<!-- 轮播图 -->
<swiper class="swiper" autoplay>
<swiper
class="swiper"
autoplay
style="padding-top: {{content.statusBarHeight}}px;"
>
<swiper-item wx:for="{{content.imgs}}" wx:key="*this">
<image mode="aspectFill" src="{{item}}" />
</swiper-item>
Expand All @@ -52,3 +62,5 @@
<view>{{item.type}}</view>
</navigator>
</view>
<!-- 色子 -->
<view style="width: 750rpx; height: 350px; background: grey"></view>
33 changes: 24 additions & 9 deletions app/pages/tab/index/index.wxs
Original file line number Diff line number Diff line change
@@ -1,16 +1,31 @@
module.exports = {
statusBarHeight: 43,
grid: [
{ type: "饭菜", tag: "饭/菜", icon: "rice" },
{ type: "汤面", tag: "面/粉", icon: "noodle" },
{ type: "粥", icon: "porridge" },
{ type: "肉类", icon: "meat" },
{ type: "面食", icon: "flour" },
{
type: "饭菜",
tag: "饭/菜",
icon: "rice",
},
{
type: "汤面",
tag: "面/粉",
icon: "noodle",
},
{
type: "粥",
icon: "porridge",
},
{
type: "肉类",
icon: "meat",
},
{
type: "面食",
icon: "flour",
},
],
/** 轮播图片 */
imgs: [
"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1584444172229&di=59165737b908cefac2a59248ae0f9c37&imgtype=0&src=http%3A%2F%2Fimg.mp.itc.cn%2Fupload%2F20161107%2F933cd537e5a541c0b72fc5eb756a455b_th.jpeg",
"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1584444285216&di=e22058000f55353ac2859e84d1074fec&imgtype=0&src=http%3A%2F%2Fpic1.win4000.com%2Fwallpaper%2Ff%2F57b158b5bcdde.jpg",
],
imgs: [""],
tags: [
/** 口味 */
["酸", "甜", "辣", "咸", "少油少盐"],
Expand Down
4 changes: 2 additions & 2 deletions project.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"miniprogramRoot": "dist/app/",
"cloudfunctionRoot": "dist/cloud/",
"setting": {
"urlCheck": true,
"urlCheck": false,
"es6": false,
"enhance": true,
"postcss": true,
Expand Down Expand Up @@ -57,4 +57,4 @@
"list": []
}
}
}
}
20 changes: 20 additions & 0 deletions server/batchUpdate.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php
require_once('./info/mysql.php');
require_once('./header/post-json.php');
require_once('./toBase64.php');


for ($i = 1; $i < 2; $i++) {
$queryString = "SELECT src FROM food WHERE fid='$i'";
$searchResult = $mysqli->query($queryString);
while ($row = mysqli_fetch_array($searchResult)) {
$src = $row["src"];
}

$newSrc = strlen(toBase64($src)) > 1000 ? toBase64($src) : $src;
$queryString2 = "UPDATE food SET src = '$newSrc' WHERE fid='$i'";
$searchResult2 = $mysqli->query($queryString2);
}

$searchResult->free();
$mysqli->close();
17 changes: 17 additions & 0 deletions server/download.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php
require_once('./info/mysql.php');
require_once('./header/post-json.php');

for ($i = 800; $i < 900; $i++) {
$queryString = "SELECT fid,src FROM food WHERE fid='$i'";
$searchResult = $mysqli->query($queryString);
while ($row = mysqli_fetch_array($searchResult)) {
$fid = $row["fid"];
$src = $row["src"];

}
file_put_contents("./imageGroup/$fid.jpg", file_get_contents($src));
}

$searchResult->free();
$mysqli->close();
5 changes: 5 additions & 0 deletions server/header/post-json.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php
header("Content-Type: text/json; charset=utf-8");
header('Access-Control-Allow-Origin:*');
header('Access-Control-Allow-Methods:POST');
header('Access-Control-Allow-Headers:x-requested-with,content-type');
12 changes: 12 additions & 0 deletions server/info/mysql.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php
$servername = "localhost:3306";
$username = "nenu";
$password = "RLs864CBe8pdM3jt";
$dbname = "nenu";
// 创建连接
$mysqli = new mysqli($servername, $username, $password, $dbname);

// 检测连接
if ($mysqli->connect_errno) {
echo "Error" . $mysqli->connect_errno . " Failed to connect to MySQL: " . $mysqli->connect_error;
}
3 changes: 3 additions & 0 deletions server/info/qq-appid.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php
$appid = "1110071558";
$secret = "oKA9M0qS8RcDBnA4";
3 changes: 3 additions & 0 deletions server/info/wx-appid.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php
$appid = "wxf4c24973a4322578";
$secret = "5be0103f9a10d11448b8a41c74c839ba";
30 changes: 30 additions & 0 deletions server/lib/curl.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
function curlGet($url)
{
$curl = curl_init(); // 启动一个CURL会话
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); // 跳过证书检查
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); // 从证书中检查 SSL 加密算法是否存在
$tmpInfo = curl_exec($curl); //返回 api 的 json 对象
//关闭 URL 请求
curl_close($curl);
return $tmpInfo; //返回 json 对象
}

function curlPost($url, $data)
{
$ch = curl_init();
$params[CURLOPT_URL] = $url; // 请求 url 地址
$params[CURLOPT_HEADER] = FALSE; // 是否返回响应头信息
$params[CURLOPT_SSL_VERIFYPEER] = false;
$params[CURLOPT_SSL_VERIFYHOST] = false;
$params[CURLOPT_RETURNTRANSFER] = true; // 是否将结果返回
$params[CURLOPT_POST] = true;
$params[CURLOPT_POSTFIELDS] = $data;
curl_setopt_array($ch, $params); // 传入 curl 参数
$p_rusult = curl_exec($ch); // 执行
curl_close($ch); // 关闭连接
return $p_rusult;
}
11 changes: 10 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4541,7 +4541,6 @@ minipass-fetch@^1.3.0, minipass-fetch@^1.3.2:
resolved "https://registry.yarnpkg.com/minipass-fetch/-/minipass-fetch-1.3.3.tgz#34c7cea038c817a8658461bf35174551dce17a0a"
integrity sha512-akCrLDWfbdAWkMLBxJEeWTdNsjML+dt5YgOI4gJ53vuO0vrmYQkUPxa6j6V65s9CcePIr2SSWqjT2EcrNseryQ==
dependencies:
encoding "^0.1.12"
minipass "^3.1.0"
minipass-sized "^1.0.3"
minizlib "^2.0.0"
Expand Down Expand Up @@ -7278,6 +7277,16 @@ write-file-atomic@^3.0.0, write-file-atomic@^3.0.3:
signal-exit "^3.0.2"
typedarray-to-buffer "^3.1.5"

wx-server-sdk@^2.4.0:
version "2.4.0"
resolved "https://registry.npm.taobao.org/wx-server-sdk/download/wx-server-sdk-2.4.0.tgz#5e14432ba0ef1c95485cf72c9359446eab392bde"
integrity sha1-XhRDK6DvHJVIXPcsk1lEbqs5K94=
dependencies:
"@cloudbase/node-sdk" "2.4.7"
protobufjs "6.8.8"
tcb-admin-node latest
tslib "^1.9.3"

wx-server-sdk@latest:
version "2.4.0"
resolved "https://registry.yarnpkg.com/wx-server-sdk/-/wx-server-sdk-2.4.0.tgz#5e14432ba0ef1c95485cf72c9359446eab392bde"
Expand Down

0 comments on commit 7be636b

Please sign in to comment.