diff --git a/miniprogram/tcb-demo-mpToWxStore/.eslintrc.js b/miniprogram/tcb-demo-mpToWxStore/.eslintrc.js new file mode 100644 index 0000000..115cc02 --- /dev/null +++ b/miniprogram/tcb-demo-mpToWxStore/.eslintrc.js @@ -0,0 +1,31 @@ +/* + * Eslint config file + * Documentation: https://eslint.org/docs/user-guide/configuring/ + * Install the Eslint extension before using this feature. + */ +module.exports = { + env: { + es6: true, + browser: true, + node: true, + }, + ecmaFeatures: { + modules: true, + }, + parserOptions: { + ecmaVersion: 2018, + sourceType: 'module', + }, + globals: { + wx: true, + App: true, + Page: true, + getCurrentPages: true, + getApp: true, + Component: true, + requirePlugin: true, + requireMiniProgram: true, + }, + // extends: 'eslint:recommended', + rules: {}, +} diff --git a/miniprogram/tcb-demo-mpToWxStore/.gitignore b/miniprogram/tcb-demo-mpToWxStore/.gitignore new file mode 100644 index 0000000..32d25be --- /dev/null +++ b/miniprogram/tcb-demo-mpToWxStore/.gitignore @@ -0,0 +1,3 @@ +miniprogram/node_modules +miniprogram/miniprogram_npm +miniprogram/package-lock.json diff --git a/miniprogram/tcb-demo-mpToWxStore/README.md b/miniprogram/tcb-demo-mpToWxStore/README.md new file mode 100644 index 0000000..333f09e --- /dev/null +++ b/miniprogram/tcb-demo-mpToWxStore/README.md @@ -0,0 +1,35 @@ +# 小程序跳转微信小店模板 + +## 说明 + +本项目为小程序跳转微信小店模板,可用于快速在小程序展示微信小店商品并支持跳转到微信小店。 + +## 配套数据管理功能 + +在[云模板](https://tcb.cloud.tencent.com/cloud-admin#/cloud-template/detail?tplId=tpl-1srBTDTiTOOprG&appName=wx_shop)中我们提供了相应的数据模型,用于配置需要在小程序中展示的微信小店和商品,可一键安装使用。 + +## 安装依赖 + +1. 安装 npm 依赖 + +```shell +npm install +``` + + 如果安装失败,请检查是否有足够权限执行命令,或尝试用更高权限安装依赖: + + ```shell + sudo npm install + ``` + +2. 构建 npm +点击微信开发者工具菜单栏中的「工具」->「构建 npm」 + +## 社区 + +欢迎添加企微群沟通交流: + +
+ +
+ diff --git a/miniprogram/tcb-demo-mpToWxStore/miniprogram/app.js b/miniprogram/tcb-demo-mpToWxStore/miniprogram/app.js new file mode 100644 index 0000000..0d530f2 --- /dev/null +++ b/miniprogram/tcb-demo-mpToWxStore/miniprogram/app.js @@ -0,0 +1,19 @@ +// app.js +App({ + onLaunch: function () { + if (!wx.cloud) { + console.error('请使用 2.2.3 或以上的基础库以使用云能力'); + } else { + wx.cloud.init({ + // env 参数说明: + // env 参数决定接下来小程序发起的云开发调用(wx.cloud.xxx)会默认请求到哪个云环境的资源 + // 此处请填入环境 ID, 环境 ID 可打开云控制台查看 + // 如不填则使用默认环境(第一个创建的环境) + env: '', + traceUser: true, + }); + } + + this.globalData = {}; + } +}); diff --git a/miniprogram/tcb-demo-mpToWxStore/miniprogram/app.json b/miniprogram/tcb-demo-mpToWxStore/miniprogram/app.json new file mode 100644 index 0000000..f4e0a9a --- /dev/null +++ b/miniprogram/tcb-demo-mpToWxStore/miniprogram/app.json @@ -0,0 +1,13 @@ +{ + "pages": [ + "pages/index/index" + ], + "window": { + "backgroundColor": "#fff", + "backgroundTextStyle": "light", + "navigationStyle":"custom" + }, + "sitemapLocation": "sitemap.json", + "style": "v2", + "lazyCodeLoading": "requiredComponents" +} \ No newline at end of file diff --git a/miniprogram/tcb-demo-mpToWxStore/miniprogram/app.wxss b/miniprogram/tcb-demo-mpToWxStore/miniprogram/app.wxss new file mode 100644 index 0000000..e69de29 diff --git a/miniprogram/tcb-demo-mpToWxStore/miniprogram/components/tipsModal/tipsModal.js b/miniprogram/tcb-demo-mpToWxStore/miniprogram/components/tipsModal/tipsModal.js new file mode 100644 index 0000000..be394f0 --- /dev/null +++ b/miniprogram/tcb-demo-mpToWxStore/miniprogram/components/tipsModal/tipsModal.js @@ -0,0 +1,46 @@ +// components/tipsModal.js +Component({ + + /** + * 组件的属性列表 + */ + properties: { + tipShow: Boolean, + title:String, + desc:String, + url:String + }, + observers: { + tipShow: function (value) { + this.setData({ isShow: value }) + } + }, + /** + * 组件的初始数据 + */ + data: { + isShow: false + }, + + /** + * 组件的方法列表 + */ + methods: { + onClose(){ + this.setData({ + isShow:false + }) + }, + copyToClipboard(){ + wx.setClipboardData({ + data:this.properties.url, + success(){ + wx.showToast({ + title: '链接已复制', + icon:"none" + }) + } + }) + } + } +}) \ No newline at end of file diff --git a/miniprogram/tcb-demo-mpToWxStore/miniprogram/components/tipsModal/tipsModal.json b/miniprogram/tcb-demo-mpToWxStore/miniprogram/components/tipsModal/tipsModal.json new file mode 100644 index 0000000..e8cfaaf --- /dev/null +++ b/miniprogram/tcb-demo-mpToWxStore/miniprogram/components/tipsModal/tipsModal.json @@ -0,0 +1,4 @@ +{ + "component": true, + "usingComponents": {} +} \ No newline at end of file diff --git a/miniprogram/tcb-demo-mpToWxStore/miniprogram/components/tipsModal/tipsModal.wxml b/miniprogram/tcb-demo-mpToWxStore/miniprogram/components/tipsModal/tipsModal.wxml new file mode 100644 index 0000000..2a567d1 --- /dev/null +++ b/miniprogram/tcb-demo-mpToWxStore/miniprogram/components/tipsModal/tipsModal.wxml @@ -0,0 +1,14 @@ + + + + + {{title}} + {{desc}} + {{url}} + + + + + + + \ No newline at end of file diff --git a/miniprogram/tcb-demo-mpToWxStore/miniprogram/components/tipsModal/tipsModal.wxss b/miniprogram/tcb-demo-mpToWxStore/miniprogram/components/tipsModal/tipsModal.wxss new file mode 100644 index 0000000..0935d84 --- /dev/null +++ b/miniprogram/tcb-demo-mpToWxStore/miniprogram/components/tipsModal/tipsModal.wxss @@ -0,0 +1,70 @@ +/* components/tipsModal.wxss */ +.modal-contianer { + position: fixed; + top: 0px; + left: 0px; + width: 100vw; + height: 100vh; + background-color: rgba(0, 0, 0, 0.40); + display: flex; + justify-content: center; + align-items: center; +} + +.modal { + box-sizing: border-box; + width: 640rpx; + background-color: #fff; + border-radius: 24rpx; + padding: 32rpx; +} +.modal-content{ + padding: 32rpx; +} +.modal-title { + text-align: center; + font-size: 20px; + font-weight: 600; + line-height: 28px; +} + +.modal-desc { + color: rgba(0, 0, 0, 0.50); + font-size: 14px; + font-weight: 400; + line-height: 18px; + margin: 12px 0px 16px 0px; +} + +.modal-link { + font-size: 14px; + font-weight: 400; + text-decoration-line: underline; + word-break: break-all; +} + +.modal-btn-group { + margin-top: 16px; + display: flex; + justify-content: space-between; + gap: 32rpx; +} + +.copy-btn { + background-color: #0052D9; + color: #fff; + font-size: 16px; + font-weight: 400; + font-size: 16px; + line-height: 24px; +} + +.close-btn { + background-color: #fff; + color: #0052D9; + border: #0052D9 1px solid; + font-size: 16px; + font-weight: 400; + font-size: 16px; + line-height: 24px; +} \ No newline at end of file diff --git a/miniprogram/tcb-demo-mpToWxStore/miniprogram/envList.js b/miniprogram/tcb-demo-mpToWxStore/miniprogram/envList.js new file mode 100644 index 0000000..e9a169e --- /dev/null +++ b/miniprogram/tcb-demo-mpToWxStore/miniprogram/envList.js @@ -0,0 +1,6 @@ +const envList = []; +const isMac = false; +module.exports = { + envList, + isMac +}; diff --git a/miniprogram/tcb-demo-mpToWxStore/miniprogram/images/banner.png b/miniprogram/tcb-demo-mpToWxStore/miniprogram/images/banner.png new file mode 100644 index 0000000..d1851d7 Binary files /dev/null and b/miniprogram/tcb-demo-mpToWxStore/miniprogram/images/banner.png differ diff --git a/miniprogram/tcb-demo-mpToWxStore/miniprogram/images/shop_home.png b/miniprogram/tcb-demo-mpToWxStore/miniprogram/images/shop_home.png new file mode 100644 index 0000000..2d9e6e9 Binary files /dev/null and b/miniprogram/tcb-demo-mpToWxStore/miniprogram/images/shop_home.png differ diff --git a/miniprogram/tcb-demo-mpToWxStore/miniprogram/images/shop_product.png b/miniprogram/tcb-demo-mpToWxStore/miniprogram/images/shop_product.png new file mode 100644 index 0000000..e08550e Binary files /dev/null and b/miniprogram/tcb-demo-mpToWxStore/miniprogram/images/shop_product.png differ diff --git a/miniprogram/tcb-demo-mpToWxStore/miniprogram/package.json b/miniprogram/tcb-demo-mpToWxStore/miniprogram/package.json new file mode 100644 index 0000000..6eaebc9 --- /dev/null +++ b/miniprogram/tcb-demo-mpToWxStore/miniprogram/package.json @@ -0,0 +1,5 @@ +{ + "dependencies": { + "@cloudbase/wx-cloud-client-sdk": "^1.2.1" + } +} diff --git a/miniprogram/tcb-demo-mpToWxStore/miniprogram/pages/index/index.js b/miniprogram/tcb-demo-mpToWxStore/miniprogram/pages/index/index.js new file mode 100644 index 0000000..261cbe4 --- /dev/null +++ b/miniprogram/tcb-demo-mpToWxStore/miniprogram/pages/index/index.js @@ -0,0 +1,81 @@ +const { init } = require('@cloudbase/wx-cloud-client-sdk') +const client = init(wx.cloud) +const models = client.models +Page({ + // wx391dea168d3accf2 10000151295117 + data: { + menuPosition: wx.getMenuButtonBoundingClientRect(), + menuItems: [ + { + key: 1, + title: "小店管理" + }, + { + key: 2, + title: "商品管理" + } + ], + selectedItemIndex: 1, + tipShow:false, + title:"", + desc:"", + url:"", + isPreview:false, + storeList:[], + storeTotal:0, + productList:[], + productTotal:0 + }, + async onLoad(){ + try{ + // 查询店铺首页了列表 + const {data:{records:storeList,total:storeTotal}} = await models.store_home_3bzb1t4.list({ + filter: { + where: {} + }, + pageSize: 10, // 分页大小,建议指定,如需设置为其它值,需要和 pageNumber 配合使用,两者同时指定才会生效 + pageNumber: 1, // 第几页 + getCount: true, // 开启用来获取总数 + }); + // 查询商品列表 + const {data:{records:productList,total:productTotal}} = await models.store_product_zh57lp5.list({ + filter: { + where: {} + }, + pageSize: 10, // 分页大小,建议指定,如需设置为其它值,需要和 pageNumber 配合使用,两者同时指定才会生效 + pageNumber: 1, // 第几页 + getCount: true, // 开启用来获取总数 + }); + this.setData({ + storeList, + storeTotal, + productList, + productTotal, + tipShow:true, + isPreview:false, + title:"使用云模板管理微信小店", + desc:"您已成功配置后台数据,可以打开下方地址对微信小店及商品进行增删改查等数据管理,配置后的数据将同步到该模板", + url:"https://tcb.cloud.tencent.com/cloud-admin#/management/content-mgr/index" + }) + }catch(e){ + this.setData({ + tipShow:true, + isPreview:true, + title:"使用云模板快速接入微信小店", + desc:"当前为体验数据,切换为真实数据请复制下方链接并在浏览器中打开,帮您快速接入微信小店,管理小店及商品数据", + url:"https://tcb.cloud.tencent.com/cloud-admin#/cloud-template/detail?tplId=tpl-1srBTDTiTOOprG&appName=wx_shop" + }) + } + }, + onChangeTab(e) { + const {key}=e.target.dataset + this.setData({ + selectedItemIndex:key + }) + }, + onOpenTipsModal(){ + this.setData({ + tipShow:true + }) + } +}); diff --git a/miniprogram/tcb-demo-mpToWxStore/miniprogram/pages/index/index.json b/miniprogram/tcb-demo-mpToWxStore/miniprogram/pages/index/index.json new file mode 100644 index 0000000..b94fbfa --- /dev/null +++ b/miniprogram/tcb-demo-mpToWxStore/miniprogram/pages/index/index.json @@ -0,0 +1,6 @@ +{ + "navigationBarBackgroundColor": "#fff", + "usingComponents": { + "tips-modal": "/components/tipsModal/tipsModal" + } +} \ No newline at end of file diff --git a/miniprogram/tcb-demo-mpToWxStore/miniprogram/pages/index/index.wxml b/miniprogram/tcb-demo-mpToWxStore/miniprogram/pages/index/index.wxml new file mode 100644 index 0000000..d8e2831 --- /dev/null +++ b/miniprogram/tcb-demo-mpToWxStore/miniprogram/pages/index/index.wxml @@ -0,0 +1,37 @@ + + + 小程序打开微信小店 + + + + + {{item.title}} + + + + + + + + + + + + + + + + 商品展示(预览数据) + + + + + + + + + + + \ No newline at end of file diff --git a/miniprogram/tcb-demo-mpToWxStore/miniprogram/pages/index/index.wxss b/miniprogram/tcb-demo-mpToWxStore/miniprogram/pages/index/index.wxss new file mode 100644 index 0000000..51b55e6 --- /dev/null +++ b/miniprogram/tcb-demo-mpToWxStore/miniprogram/pages/index/index.wxss @@ -0,0 +1,34 @@ +.page-title{ + font-size: 19px; + font-weight: 500; + padding-left: 32rpx; +} +.banner-container{ + display: flex; + justify-content: center; + padding-top: 16px; + padding-bottom: 16px; +} +.banner{ + width: 686rpx; + height: 240rpx; +} +.tabs{ + padding-left: 32rpx; + padding-right: 32rpx; +} +.tabs-header{ + display: flex; + justify-content: space-around; +} +.tabs-header-item-normal{ + line-height: 43px; +} +.tabs-header-item-selected{ + line-height: 43px; + border-bottom: 2px #0052D9 solid; + color: #0052D9; +} +.tabs-body{ + padding-top: 16px; +} \ No newline at end of file diff --git a/miniprogram/tcb-demo-mpToWxStore/miniprogram/sitemap.json b/miniprogram/tcb-demo-mpToWxStore/miniprogram/sitemap.json new file mode 100644 index 0000000..27b2b26 --- /dev/null +++ b/miniprogram/tcb-demo-mpToWxStore/miniprogram/sitemap.json @@ -0,0 +1,7 @@ +{ + "desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html", + "rules": [{ + "action": "allow", + "page": "*" + }] +} \ No newline at end of file diff --git a/miniprogram/tcb-demo-mpToWxStore/project.config.json b/miniprogram/tcb-demo-mpToWxStore/project.config.json new file mode 100644 index 0000000..8574182 --- /dev/null +++ b/miniprogram/tcb-demo-mpToWxStore/project.config.json @@ -0,0 +1,70 @@ +{ + "miniprogramRoot": "miniprogram/", + "cloudfunctionRoot": "cloudfunctions/", + "setting": { + "urlCheck": true, + "es6": true, + "enhance": true, + "postcss": true, + "preloadBackgroundData": false, + "minified": true, + "newFeature": true, + "coverView": true, + "nodeModules": false, + "autoAudits": false, + "showShadowRootInWxmlPanel": true, + "scopeDataCheck": false, + "uglifyFileName": false, + "checkInvalidKey": true, + "checkSiteMap": true, + "uploadWithSourceMap": true, + "compileHotReLoad": false, + "useMultiFrameRuntime": true, + "useApiHook": true, + "useApiHostProcess": true, + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + }, + "enableEngineNative": false, + "useIsolateContext": true, + "useCompilerModule": true, + "userConfirmedUseCompilerModuleSwitch": false, + "userConfirmedBundleSwitch": false, + "packNpmManually": false, + "packNpmRelationList": [], + "minifyWXSS": true + }, + "appid": "wxc35ad965824811ef", + "projectname": "quickstart-wx-cloud", + "libVersion": "latest", + "cloudfunctionTemplateRoot": "cloudfunctionTemplate/", + "condition": { + "search": { + "list": [] + }, + "conversation": { + "list": [] + }, + "plugin": { + "list": [] + }, + "game": { + "list": [] + }, + "miniprogram": { + "list": [] + } + }, + "compileType": "miniprogram", + "srcMiniprogramRoot": "miniprogram/", + "packOptions": { + "ignore": [], + "include": [] + }, + "editorSetting": { + "tabIndent": "insertSpaces", + "tabSize": 2 + } +} \ No newline at end of file diff --git a/miniprogram/tcb-demo-mpToWxStore/project.private.config.json b/miniprogram/tcb-demo-mpToWxStore/project.private.config.json new file mode 100644 index 0000000..3efde60 --- /dev/null +++ b/miniprogram/tcb-demo-mpToWxStore/project.private.config.json @@ -0,0 +1,9 @@ +{ + "setting": { + "compileHotReLoad": true, + "urlCheck": true + }, + "condition": {}, + "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", + "projectname": "miniprogram-39" +} \ No newline at end of file diff --git a/miniprogram/tcb-demo-mpToWxStore/uploadCloudFunction.sh b/miniprogram/tcb-demo-mpToWxStore/uploadCloudFunction.sh new file mode 100644 index 0000000..df311b3 --- /dev/null +++ b/miniprogram/tcb-demo-mpToWxStore/uploadCloudFunction.sh @@ -0,0 +1 @@ +${installPath} cloud functions deploy --e ${envId} --n quickstartFunctions --r --project ${projectPath} \ No newline at end of file diff --git a/miniprogram/tcb-shop/.gitignore b/miniprogram/tcb-shop/.gitignore index 68a200f..e69de29 100644 --- a/miniprogram/tcb-shop/.gitignore +++ b/miniprogram/tcb-shop/.gitignore @@ -1,16 +0,0 @@ -node_modules/ -yarn-error.log -miniprogram/ -miniprogram_npm/ -miniprogram_dist/ -.DS_Store -$node_modules/ -.history/ -**/dist -components/**/*.lock -components/**/package-lock.json -package-lock.json -yarn.lock -project.private.config.json -.eslintcache -cloudfunctions/ \ No newline at end of file