Demo
H5 預覽: http://h5.tinyshop.rageframe.com
uni-app發佈頁: https://m3w.cn/rageframewsc
後臺預覽: http://demo2.rageframe.com/backend
賬號: demo
密碼: 123456
TinyShop項目地址
前端開源地址: https://github.com/stavyan/TinyShop-UniApp
後端開源地址: https://github.com/jianyan74/TinyShop
一款基於 RageFrame2 的免費開源的基礎銷售功能的微商城
前端基於 uni-app,一端發佈多端通用,目前已經適配 H5、微信小程序、QQ小程序、Ios App、Android App。目前開源的版本功能爲 V1 版,更多增強功能(V2、V3)敬請期待。
一、安裝 RageFrame (2.6.0以上)
RageFrame 遵循 Apache2 開源協議發佈,並提供免費使用。
項目介紹:https://github.com/jianyan74/rageframe2
安裝文檔:https://github.com/jianyan74/rageframe2/blob/master/docs/guide-zh-CN/start-installation.md
環境要求
- PHP >= 7.2 (卸載郵件依賴 7.1.3 亦可,win7下配置php7.2到PATH)
- PHP cURL 擴展
- PHP OpenSSL 擴展
- PHP fileinfo 拓展 素材管理模塊需要用到
- Mysql >= 5.7
- Apache 或 Nginx
- Composer
用於管理第三方擴展包,
win環境在https://getcomposer.org/download/下載Composer-Setup.exe安裝,
linux寶塔
在軟件商店安裝需要的php7.2版本
登陸ssh或者用面板自帶的“寶塔SSH終端”
運行命令:
rm
-f /usr/bin/php
比如要改到php7.2版本的composer就要再次運行一下的命令:
ln
-sf /www/server/php/72/bin/php /usr/bin/php
默認安裝的PHP是禁用了proc_open與putenv兩個函數,
打開就可以愉快的composer install了!
- 安裝CA證書 (windows開發環境下)
CA證書參考:
https://blog.csdn.net/ijijni/article/details/86537234
安裝
1、克隆
git clone https://github.com/jianyan74/rageframe2.git
2、進入目錄
cd rageframe2
3、安裝依賴
// 如果你只有 php 7.1 也可以忽略版本進行安裝 php composer.phar install --ignore-platform-reqs
php composer.phar install
遇到問題:
Warning: putenv() has been disabled for security reasons in...
編輯php.ini文件
disable_functions = scandir,passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,pfsockopen,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,fsocket,fsockopen
去掉putenv或者在disable_functions 添加;分號註釋,
保存並重起php即可。
使用代理或者使用國內源:
解決方法,更改 Packagist 爲國內鏡像,不知道會不會對後續操作有影響,反正現在是可以了:
composer config -g repo.packagist composer https://packagist.phpcomposer.com
Cloning failed using an ssh key for authentication, enter your GitHub credential
s to access private repos
Head to https://github.com/settings/tokens/new?scopes=repo&description=Composer+
on+%5B0x77489020%5D+ANOMALY%3A+meaningless+REX+prefix+used%0D%0AWIN7AN3+2020-04-
12+2251
to retrieve a token. It will be stored in "C:/Users/Admin/AppData/Roaming/Compos
er/auth.json" for future use by Composer.
Token (hidden):
Failed to download kartik-v/yii2-widget-datepicker from source: The 'https:/
/api.github.com/' URL could not be accessed: HTTP/1.0 400 Bad Request
Now trying to download from dist
重新獲取token:
https://blog.csdn.net/weixin_34062329/article/details/86000735
- Installing swoole/ide-helper (dev-master a7bae64): Failed to update https://
github.com/swoole/ide-helper.git in cache, package installation for swoole/ide-h
elper might fail.
Cloning a7bae64317 from cache
Failed to download swoole/ide-helper from source: Failed to execute git clon
e --no-checkout "C:/Users/Admin/AppData/Local/Composer/vcs/https---github.com-sw
oole-ide-helper.git/" "E:\WebSite\PHP\www\llj\ragefram\rageframe2\vendor\swoole\
ide-helper" --dissociate --reference "C:/Users/Admin/AppData/Local/Composer/vcs/
https---github.com-swoole-ide-helper.git/" && cd /D "E:\WebSite\PHP\www\llj\rage
fram\rageframe2\vendor\swoole\ide-helper" && git remote set-url origin "https://
github.com/swoole/ide-helper.git.git" && git remote add composer "https://github
.com/swoole/ide-helper.git.git"
Cloning into 'E:\WebSite\PHP\www\llj\ragefram\rageframe2\vendor\swoole\ide-helpe
r'...
done.
fatal: repack: Expecting full hex object ID lines only from pack-objects.
fatal: cannot repack to clean up
Now trying to download from dist
- Installing swoole/ide-helper (dev-master a7bae64): Downloading (connecting..
Downloading (100%)
- Installing yiisoft/yii2-bootstrap (2.0.10): Downloading (100%)
- Installing yiisoft/yii2-debug (2.0.14): Downloading (100%)
- Installing fzaninotto/faker (v1.9.1): Downloading (100%)
- Installing yiisoft/yii2-faker (2.0.4): Downloading (100%)
- Installing phpspec/php-diff (v1.1.0): Downloading (100%)
- Installing bower-asset/typeahead.js (v0.11.1): Downloading (connecting...)
Failed to download bower-asset/typeahead.js from dist: The 'https://api.github
.com/repos/twitter/typeahead.js/zipball/588440f66559714280628a4f9799f0c4eb880a4a
' URL could not be accessed: HTTP/1.0 400 Bad Request
Now trying to download from source
- Installing bower-asset/typeahead.js (v0.11.1): Cloning 588440f665
[RuntimeException]
Failed to execute git clone --no-checkout "https://7f208908497b155a0e941435
a1c1239f5b113d26%0A%5B0x77489020%5D%20ANOMALY%3A%20meaningless%20REX%20pref
ix%20used:***@github.com/twitter/typeahead.js.git" "E:\WebSite\PHP\www\llj\
ragefram\rageframe2\vendor\bower-asset\typeahead.js" && cd /D "E:\WebSite\P
HP\www\llj\ragefram\rageframe2\vendor\bower-asset\typeahead.js" && git remo
te add composer "https://7f208908497b155a0e941435a1c1239f5b113d26%0A%5B0x77
489020%5D%20ANOMALY%3A%20meaningless%20REX%20prefix%20used:***@github.com/t
witter/typeahead.js.git" && git fetch composer && git remote set-url origin
"https://github.com/twitter/typeahead.js.git" && git remote set-url compos
er "https://github.com/twitter/typeahead.js.git"
Cloning into 'E:\WebSite\PHP\www\llj\ragefram\rageframe2\vendor\bower-asset
\typeahead.js'...
fatal:***@github.com/twitter/typeahead.js.git/': URL using bad/illegal form
at or missing URL
install [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--no-c
ustom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [--no-suggest
] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative]
[--apcu-autoloader] [--ignore-platform-reqs] [--] [<packages>]...
4、初始化項目
php init // 然後輸入0回車,再輸入yes回車
5、配置數據庫信息
找到 common/config/main-local.php 並配置相應的信息, 注意要先創建好數據庫
6、安裝數據庫(Mysql5.7及以上)
php ./yii migrate/up
7、初始化賬號密碼,一鍵創建總管理員賬號密碼(注意保存)
php ./yii password/init
截止到這裏就安裝完成了,可以去配置站點了,下面(8、9步驟)的都是根據自己實際的情況去執行
8、建議更新第三方擴展包(可選)
php composer.phar update
9、Linux 下文件緩存權限授權
Linux 環境下如果是文件緩存去 backend/runtime
目錄執行一下 chmod -R 777 cache
,不執行可能會造成修改了網站設置緩存不生效的情況
站點配置
注意:Nginx/IIS 先要設置好僞靜態,Apache 默認已配置
僞靜態
目錄
- Nginx
- Apache
- IIS
Nginx
推薦配置
location / { try_files $uri $uri/ /index.php$is_args$args; } location /backend { try_files $uri $uri/ /backend/index.php$is_args$args; } location /api { try_files $uri $uri/ /api/index.php$is_args$args; } location /merchant { try_files $uri $uri/ /merchant/index.php$is_args$args; } location /merapi { try_files $uri $uri/ /merapi/index.php$is_args$args; } location /html5 { try_files $uri $uri/ /html5/index.php$is_args$args; } location /oauth2 { try_files $uri $uri/ /oauth2/index.php$is_args$args; }
類似Apache的配置
location / { index index.html index.htm index.php; if (!-e $request_filename) { rewrite ^/backend(.*)$ /backend/index.php?s=$1 last; rewrite ^/merchant(.*)$ /merchant/index.php?s=$1 last; rewrite ^/merapi(.*)$ /merapi/index.php?s=$1 last; rewrite ^/api(.*)$ /api/index.php?s=$1 last; rewrite ^/html5(.*)$ /html5/index.php?s=$1 last; rewrite ^/oauth2(.*)$ /oauth2/index.php?s=$1 last; rewrite ^/(.*)$ /index.php?s=$1 last; break; } #autoindex on; }
Apache
注意系統默認自帶了.htaccess,所以環境如果是apache可以不用再配置
Options +FollowSymLinks IndexIgnore */* RewriteEngine on # if a directory or a file exists, use it directly RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d # otherwise forward it to index.php RewriteRule . index.php
IIS...
https://github.com/jianyan74/rageframe2/blob/master/docs/guide-zh-CN/start-rewrite.md
站點指向目錄爲當前項目的web下
例如:
/path/to/rageframe2/web/
訪問說明
應用 | Url |
---|---|
後臺 | 當前域名/backend |
商戶 | 當前域名/merchant |
商戶接口 | 當前域名/merapi |
Html5 | 當前域名/html5 |
Api | 當前域名/api |
OAuth2 | 當前域名/oauth2 |
安裝成功後如果需要微信公衆號管理、商戶管理等等功能,請到 系統管理->應用管理 進行安裝插件
二、安裝TinyShop
git clone https://github.com/jianyan74/TinyShop.git
2、拷貝進 RageFrame 根目錄的 addons 目錄下
3、RageFrame 後臺進入 系統管理->應用管理->安裝插件->找到在微商城進行安裝
4、刷新整個後臺頁面後進行查看
三,前端 uni-app
安裝運行
1. HBuilderX導入
- 使用HBuilderX導入
- 點擊菜單欄 -> 運行 直接運行對應設備
2. vue-cli命令運行
推薦使用yarn命令,使用npm/cnpm會存在報錯問題。
- 去github上clone項目至本地
- 進入項目目錄,安裝相關依賴
// 安裝yarn命令 npm i -g yarn // 安裝依賴 yarn
3. 運行到指定平臺
// 運行到H5 yarn serve // 運行至對應的小程序平臺 yarn dev:PLATFORM // PLATFORM的值可以是 mp-weixin mp-alipay mp-baidu mp-toutiao mp-qq
接口配置文件:/src/api/params.js
// 主機地址
const hostUrl = "http://localhost:8080";
// 後臺接口請求地址
const baseUrl = "http://b.com/api";
小程序微信登錄有點問題:
Request URL: http://b.com/api/tiny-shop/v1/third-party/wechat-mp
Request Method: POST
type: "GuzzleHttp\Exception\RequestException"
file: "rageframe2\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php"
errorMessage: "cURL error 60: SSL certificate problem: unable to get local issuer certificate (see https://curl.haxx.se/libcurl/c/libcurl-errors.html)"
line: 201
rageframe2\addons\TinyShop\api\modules\v1\controllers\ThirdPartyController.php
68行:public function actionWechatMp(){}
https://curl.haxx.se/docs/caextract.html
下載cacert.pem
並在php.ini文件添加
curl.cainfo="D:/php72/extras/ssl/cacert.pem"
openssl.cafile="D:/php72/extras/ssl/cacert.pem"
參考:
https://blog.csdn.net/ijijni/article/details/86537234
4. 打包至線上部署
// H5打包 yarn build // 打包至對應的小程序平臺 yarn build:PLATFORM // 平臺信息同上 //HbuilderX 用android studio 本地打包app ************ https://blog.csdn.net/cuberk/article/details/103647190 // Android 平臺 HTML5+ SDK的集成(HBuilder離線打包) ************ https://blog.csdn.net/qq_33337504/article/details/80061055 //HBuilderX生成本地打包App資源 ************* https://ask.dcloud.net.cn/question/60254 //Android離線打包(支持廣告) https://ask.dcloud.net.cn/article/13141 //uni-app離線打包Android平臺注意事項 https://ask.dcloud.net.cn/article/35139 //APP: //Android平臺本地(離線)打包指南 - Android Studio https://ask.dcloud.net.cn/article/508 //iOS離線打包 https://ask.dcloud.net.cn/article/41 //DCloud appid 用途/作用/使用說明 https://ask.dcloud.net.cn/article/35907 //Android平臺雲端打包 - 公共測試證書 https://ask.dcloud.net.cn/article/36522 //iOS證書(.p12)和描述文件(.mobileprovision)申請 https://ask.dcloud.net.cn/article/152
導出本地app編譯包時,遇到錯誤:
未檢測到微信web開發者工具,即使開發App也需要此工具。如已安裝,請確認路徑配置是否正確(HBuilderX設置-運行配置-微信開發者工具路徑),或檢查是否微信工具版本過低
解決方法:
重新安裝正式版微信開發工具