diff --git a/miniprogram/app.js b/miniprogram/app.js
index 5ee20e3f259b1a58b394413910f2cbae4af723b3..a1ac2115e3cd472fc5582b08691b19050b9bd752 100644
--- a/miniprogram/app.js
+++ b/miniprogram/app.js
@@ -1,11 +1,14 @@
// app.js
App({
+ basePage:'pages/aiBot/aiBot',
homePageArticleId: 32,
lifePageArricleId: 35,
wxProgramConfig: {
authorPageConfig: {
+ cloudEmail: "1575057249@qq.com",
+ cloudPwd: "U2FsdGVkX1+jfEkF2OXTQ5iIG4mrYc5/TLOiIntyENU=",
title: "记忆碎片",
- userImageUrl: 'https://yongma16.xyz/staticFile/common/img/logo.png',
+ userImageUrl: 'https://yongma16.xyz/staticFile/common/img/aiTop.jpg',
loginTitle: '点击授权',
detailInfo: '关于:code笔记',
nextPage: "/pages/home/home",
@@ -13,6 +16,7 @@ App({
userName: '月牙天冲',
designPlaceholder: '自定义名称',
joinTitle: '微信登录',
+ shopBtnTitle: '虚拟资产',
isOldVersion: false
},
homePageConfig: {
@@ -61,7 +65,8 @@ App({
}
},
aboutPageConfig: {
- articleId: 35
+ articleId: 35,
+ title:'个人信息'
}
},
loginStatus: '',
@@ -77,7 +82,8 @@ App({
targetItem: {},
},
remoteConfig: {
- baseUrl: 'https://yongma16.xyz'
+ baseUrl: 'https://yongma16.xyz',
+ baseCloudUrl:'https://yongma16.xyz/cloudApi/api/',
},
// 引入`towxml3.0`解析方法
towxml: require('/towxml/index'),
@@ -166,7 +172,7 @@ App({
if (res.data.data && res.data.data[0].option) {
that.wxProgramConfig = JSON.parse(res.data.data[0].option)
wx.navigateTo({
- url: 'pages/index/index',
+ url: that.basePage,
success: function (res) {
// 通过 eventChannel 向被打开页面传送数据
console.log('res', res)
@@ -175,7 +181,7 @@ App({
}
else {
wx.navigateTo({
- url: 'pages/index/index',
+ url: that.basePage,
success: function (res) {
// 通过 eventChannel 向被打开页面传送数据
console.log('res', res)
@@ -189,7 +195,7 @@ App({
success: (loadRes) => { console.log(loadRes) },
})
wx.navigateTo({
- url: 'pages/index/index',
+ url: that.basePage,
success: function (res) {
// 通过 eventChannel 向被打开页面传送数据
console.log('res', res)
@@ -215,7 +221,7 @@ App({
console.log('success')
} else {
wx.navigateTo({
- url: 'pages/index/index',
+ url: this.basePage,
success: function (res) {
// 通过 eventChannel 向被打开页面传送数据
console.log('res', res)
diff --git a/miniprogram/app.json b/miniprogram/app.json
index 74c9741f4ab86de7d546c70aa0f27ed0d1a84f7e..0c898f6dd62de04d17f5f14c18721ada93fb3c63 100644
--- a/miniprogram/app.json
+++ b/miniprogram/app.json
@@ -1,19 +1,21 @@
{
- "pages": [
- "pages/index/index",
- "pages/home/home",
- "pages/homeContent/homeContent",
- "pages/blog/blog",
- "pages/life/life",
- "pages/future/future"
- ],
- "window": {
- "backgroundColor": "#F6F6F6",
- "backgroundTextStyle": "light",
- "navigationBarBackgroundColor": "#262626",
- "navigationBarTitleText": "yma16博客",
- "navigationBarTextStyle": "white"
- },
- "sitemapLocation": "sitemap.json",
- "style": "v2"
+ "pages": [
+ "pages/index/index",
+ "pages/home/home",
+ "pages/homeContent/homeContent",
+ "pages/blog/blog",
+ "pages/life/life",
+ "pages/future/future",
+ "pages/shop/shop",
+ "pages/aiBot/aiBot"
+ ],
+ "window": {
+ "backgroundColor": "#F6F6F6",
+ "backgroundTextStyle": "light",
+ "navigationBarBackgroundColor": "#262626",
+ "navigationBarTitleText": "yma16博客",
+ "navigationBarTextStyle": "white"
+ },
+ "sitemapLocation": "sitemap.json",
+ "style": "v2"
}
\ No newline at end of file
diff --git a/miniprogram/pages/aiBot/aiBot.js b/miniprogram/pages/aiBot/aiBot.js
new file mode 100644
index 0000000000000000000000000000000000000000..ad596d82996b5e6becefab3f37fb96b34365cbc5
--- /dev/null
+++ b/miniprogram/pages/aiBot/aiBot.js
@@ -0,0 +1,260 @@
+// pages/aiBot/aiBot.js
+
+const app = getApp();
+Page({
+
+ /**
+ * 页面的初始数据
+ */
+ data: {
+ currentUserInfo: {
+ nickName: '',
+ avatarUrl: 'https://profile-avatar.csdnimg.cn/8bea3d4b0c56486691de8f54fb649fa4_qq_38870145.jpg!1',
+ },
+ saveKey: 'aiBot',
+ baseCloudUrl: app.remoteConfig.baseCloudUrl,
+ password: app.remoteConfig.cloudPwd || "U2FsdGVkX1+jfEkF2OXTQ5iIG4mrYc5/TLOiIntyENU=",
+ username: app.remoteConfig.cloudEmail || "1575057249@qq.com",
+ token: '',
+ currenTime: '',
+ isLoading: false,
+ searchOpenAiText: '画一只猫',
+ chatObjConfig: {
+ option: [
+ // {
+ // question: '',
+ // answer: '',
+ // isEdit: true,
+ // createTime: ''
+ // }
+ ],
+ currentIndex: 0,
+ errorMsg: 'openai的服务器异常!'
+ },
+ layoutConfig: {
+ showPasteBtn: false,
+ showTopBtn: false,
+ introduceText: 'api介绍',
+ useText: '使用',
+ returnText: '返回介绍',
+ sendText: '发送',
+ searchText: '请输入关键词进行对话',
+ reportText: '复制数据',
+ copyText: '复制',
+ pasteText: '粘贴',
+ upText: "↑",
+ downText: "↓",
+ errorMsg: 'openai的服务器异常!',
+ emptyText: '欢迎使用aibot',
+ storageKey: 'openAiOptionsConfig',
+ permissionTitle: '很抱歉您没有权限!',
+ permissionContent: '请联系微信号:cse-yma16\r\n 需要1元开通权限\r\n1元可支持100条消息!',
+ wxInfoImg: 'https://yongma16.xyz/staticFile/common/img/userInfo.png',
+ limitMsgCount: 10,
+ confirmText: '添加微信',
+ cancelText: '返回'
+ },
+ aiConfig: {
+ avatarUrl: 'https://yongma16.xyz/staticFile/common/img/aiTop.jpg',
+ bgUrl: 'https://yongma16.xyz/staticFile/common/img/aiBg.jpg',
+ nickName: 'openai',
+ },
+ },
+ getUserToken() {
+ const that = this
+ wx.showLoading({
+ title: 'gen token loading',
+ });
+ wx.request({
+ url: this.data.baseCloudUrl + 'token/gen',
+ method: 'POST',
+ data: {
+ username: this.data.username,
+ password: this.data.password
+ },
+ success: (res => {
+ that.setData({
+ token: res.data.token
+ })
+ wx.hideLoading()
+ }),
+ fail: r => {
+ console.log('cloud r', r)
+ wx.hideLoading()
+ }
+ })
+ },
+ getCurrentTime() {
+ const now = new Date()
+ const year = now.getFullYear()
+ const month = now.getMonth()
+ const date = now.getDate()
+ const hour = now.getHours()
+ const minutes = now.getMinutes()
+ const second = now.getSeconds()
+ const formatNum = (n) => {
+ return n > 9 ? n.toString() : '0' + n
+ }
+ return `${year}-${formatNum(month + 1)}-${formatNum(date)} ${formatNum(hour)}:${formatNum(minutes)}:${formatNum(second)}`
+ },
+ bindKeyInput(e) {
+ console.log('e.detail.value', e.detail.value)
+ this.setData({
+ searchOpenAiText: e.detail.value
+ })
+ },
+ scrollToBottom() {
+ const index = this.data.chatObjConfig.option.length - 1
+ this.setData({
+ toView: `chat-mode${index}`
+ })
+ },
+
+ search(e) {
+ this.scrollToBottom()
+ if (!this.data.searchOpenAiText) {
+ wx.showModal({
+ cancelColor: 'cancelColor',
+ title: '请输入!'
+ })
+ return
+ }
+ wx.showLoading({
+ title: '加载中',
+ })
+ this.setData({
+ isLoading: true
+ })
+ const that = this
+
+ return new Promise((resolve, reject) => {
+ wx.request({
+ url: that.data.baseCloudUrl + '/chat/bot',
+ method: 'POST',
+ header: {
+ Authorization: `bearer ${that.data.token}`
+ },
+ data: {
+ user: 'qwerqwre',
+ query: that.data.searchOpenAiText
+ },
+ success: (res) => {
+ console.log(res, 'res')
+ const data = res.data.data
+ const option = that.data.chatObjConfig.option
+ console.log('data', data)
+ const choices = data.messages[2]
+ const answer = choices?.content
+ option.push({
+ question: that.data.searchOpenAiText,
+ answer: answer,
+ answerMarkdown: app.changeMrkdownText(answer),
+ createTime: that.getCurrentTime(),
+ isEdit: false,
+ })
+ const chatObjConfig = {
+ option: option
+ }
+
+ that.setData({
+ isLoading: false,
+ searchOpenAiText: '',
+ chatObjConfig: chatObjConfig
+ })
+ wx.hideLoading()
+ that.scrollToBottom()
+ resolve(res)
+ console.log('that.data.chatObjConfig.option', that.data.chatObjConfig.option)
+
+ },
+ fail: error => {
+ that.setData({
+ isLoading: false
+ })
+ wx.hideLoading()
+ }
+ });
+ })
+ },
+
+ /**
+ * 生命周期函数--监听页面加载
+ */
+ onLoad(options) {
+ this.getUserToken()
+ this.setData({
+ currenTime: this.getCurrentTime()
+ })
+
+ const currentUserInfo = wx.getStorageSync('currentUserInfo')
+ if (currentUserInfo && currentUserInfo.nickName) {
+ console.log('currentUserInfo', currentUserInfo)
+ this.setData({
+ currentUserInfo: currentUserInfo
+ })
+ }
+
+ // 缓存
+ const openAiOptionsConfig = wx.getStorageSync(this.data.saveKey)
+
+ if (openAiOptionsConfig) {
+ this.setData({
+ chatObjConfig: openAiOptionsConfig,
+ })
+ }
+
+ },
+
+ /**
+ * 生命周期函数--监听页面初次渲染完成
+ */
+ onReady() {
+
+ },
+
+ /**
+ * 生命周期函数--监听页面显示
+ */
+ onShow() {
+
+ },
+
+ /**
+ * 生命周期函数--监听页面隐藏
+ */
+ onHide() {
+
+ },
+
+ /**
+ * 生命周期函数--监听页面卸载
+ */
+ onUnload() {
+ // 缓存
+
+ if (this.data.openAiOptionsConfig) {
+ wx.setStorageSync(this.data.saveKey, this.data.openAiOptionsConfig)
+ }
+ },
+
+ /**
+ * 页面相关事件处理函数--监听用户下拉动作
+ */
+ onPullDownRefresh() {
+
+ },
+
+ /**
+ * 页面上拉触底事件的处理函数
+ */
+ onReachBottom() {
+
+ },
+
+ /**
+ * 用户点击右上角分享
+ */
+ onShareAppMessage() {
+
+ }
+})
\ No newline at end of file
diff --git a/miniprogram/pages/aiBot/aiBot.json b/miniprogram/pages/aiBot/aiBot.json
new file mode 100644
index 0000000000000000000000000000000000000000..caf09fa9057d192f4debf1b1ef367093ba2feb0f
--- /dev/null
+++ b/miniprogram/pages/aiBot/aiBot.json
@@ -0,0 +1,5 @@
+{
+ "usingComponents": {
+ "towxml":"/towxml/towxml"
+ }
+}
\ No newline at end of file
diff --git a/miniprogram/pages/aiBot/aiBot.wxml b/miniprogram/pages/aiBot/aiBot.wxml
new file mode 100644
index 0000000000000000000000000000000000000000..73410659d8d529eb701d845f66c1d8cd262b1dae
--- /dev/null
+++ b/miniprogram/pages/aiBot/aiBot.wxml
@@ -0,0 +1,86 @@
+
+
+
+
+
+
+ {{item.createTime}}
+
+
+
+
+
+
+ {{item.question}}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{currenTime}}
+
+
+
+
+
+
+
+
+
+
+
+ {{layoutConfig.emptyText}}
+
+
+
+
+
+
+
+
+ {{layoutConfig.sendText}}
+
+
+
+
+
+
\ No newline at end of file
diff --git a/miniprogram/pages/aiBot/aiBot.wxss b/miniprogram/pages/aiBot/aiBot.wxss
new file mode 100644
index 0000000000000000000000000000000000000000..75f799bee3d325c743b75802a46efc1f9656c9a4
--- /dev/null
+++ b/miniprogram/pages/aiBot/aiBot.wxss
@@ -0,0 +1,253 @@
+/* pages/aiBot/aiBot.wxss */
+
+.container-box{
+ position: relative;
+ width: 100vw;
+ height: 100vh;
+ background: rgb(245, 245, 245);
+ overflow: hidden;
+ box-sizing: border-box;
+}
+
+.container-box-article {
+ position: relative;
+ padding-top:0px;
+ width: 100%;
+ height: calc(100vh - 88px);
+ box-shadow: inset 5px 5px #262626;
+ overflow: auto;
+ user-select: text;
+}
+
+.scroll-answer {
+ height: calc(100vh - 100px);
+}
+
+.chat-container {
+ width: 100%;
+ height: 100vh;
+ overflow-y: auto;
+ overflow-x: hidden;
+ position: relative;
+}
+
+.paste-btn {
+ background: rgba(16, 116, 187);
+ color: #ffffff;
+ /* transform: scale(.7); */
+ border-radius: 5px;
+}
+
+.clear-btn {
+ background: rgba(16, 116, 187);
+ color: #ffffff;
+ /* transform: scale(.7); */
+ border-radius: 5px;
+}
+
+.paste-btn:hover {
+ border: none;
+ background: rgb(221, 0, 66);
+}
+
+.user-image-box {
+ width: 300px;
+ text-align: center;
+ align-items: center;
+}
+
+.user-image {
+ position: relative;
+ width: 15px;
+ height: 15px;
+ border-radius: 50%;
+ background-color: transparent;
+ background: transparent;
+}
+
+.ai-image {
+ position: relative;
+ width: 20px;
+ height: 20px;
+ border-radius: 50%;
+}
+
+.questioned-box-container {
+ display: flex;
+}
+
+.questioned-box {
+ position: relative;
+ max-width: calc(100vw - 90px);
+ height: auto;
+ overflow-x: auto;
+ background-color: rgb(255, 255, 255);
+ border-radius: 10px;
+ right: -5px;
+ padding: 0 10px;
+ z-index: 999;
+ color: #333;
+ font-family: PingFang SC, Lantinghei SC, Microsoft Yahei, Hiragino Sans GB, Microsoft Sans Serif, WenQuanYi Micro Hei, sans-serif;
+ font-weight: 300;
+ font-size: 32rpx;
+ user-select: text;
+ box-shadow: -5rpx 3rpx 1rpx -4rpx #c8c3c3;
+}
+
+.questioned-box-poly {
+ position: relative;
+ top: 15px;
+ width: 0;
+ height: 0;
+ border-radius: 5px;
+ border-top: 10px solid transparent;
+ border-bottom: 10px solid transparent;
+ border-left: 12px solid rgb(255, 255, 255);
+ box-shadow: 0rpx 0rpx 0rpx 0rpx #c8c3c3;
+}
+.clear-paste-btn{
+ width:70%;
+ display: flex;
+}
+.submit-input {
+ box-shadow: 0 2rpx 5rpx 5rpx #c8c3c3;
+ width: 70%;
+}
+
+.send-input {
+ height: 60px;
+ background: rgba(255, 255, 255, .8);
+ width: 100%;
+ height: 100px;
+ position: relative;
+ text-indent: 8px;
+ /* padding-left: 5px; */
+ color: rgb(0, 114, 221);
+}
+.send-btn::after{
+ position: absolute;
+ left:0;
+ top:0;
+ width: 100px;
+ height: 100%;
+ background-color: rgba(255, 255, 255, .8);
+}
+
+.up-down-btn{
+ width:30%;
+}
+
+.send-btn {
+ box-shadow: 0 2rpx 5rpx 5rpx #c8c3c3;
+ width: 30%;
+ background-color:rgba(16, 116, 187);
+ color: #ffffff;
+ height: 100px;
+ line-height: 100px;
+ /* border-radius: 10px 0 0 10px; */
+ text-align: center;
+}
+
+.empty-reponse-msg {
+ position: relative;
+ max-width: calc(100vw - 90px);
+ height: auto;
+ overflow-x: auto;
+ background-color: rgb(255, 255, 255);
+ border-radius: 10px;
+ left: -5px;
+ padding: 0 10px;
+ z-index: 999;
+ color: #333;
+ font-family: PingFang SC, Lantinghei SC, Microsoft Yahei, Hiragino Sans GB, Microsoft Sans Serif, WenQuanYi Micro Hei, sans-serif;
+ font-weight: 300;
+ font-size: 32rpx;
+ user-select: text;
+}
+
+.create-time {
+ width: 100%;
+ text-align: center;
+ color: rgb(255, 255, 255);
+ background: rgb(218, 218, 218);
+ margin: 5px auto;
+ box-shadow: inset 0 1rpx 2rpx 1rpx rgba(0, 0, 0, 0.2);
+}
+
+.form-response-user {
+ background-color: rgba(0, 72, 94, 0);
+ color: #fff;
+}
+
+.form-response-box-poly {
+ position: relative;
+ top: 15px;
+ width: 0;
+ height: 0;
+ border-radius: 5px;
+ border-top: 10px solid transparent;
+ border-bottom: 10px solid transparent;
+ border-right: 12px solid rgb(255, 255, 255);
+}
+
+.form-response-box {
+ position: relative;
+ max-width: calc(100vw - 50px);
+ /* word-break:keep-all; */
+ /* white-space: pre-wrap; */
+ white-space: pre-line;
+ height: auto;
+ overflow-x: auto;
+ background-color: rgb(255, 255, 255);
+ border-radius: 10px;
+ color: #333;
+ font-family: PingFang SC, Lantinghei SC, Microsoft Yahei, Hiragino Sans GB, Microsoft Sans Serif, WenQuanYi Micro Hei, sans-serif;
+ font-weight: 300;
+ font-size: 32rpx;
+ left: -5px;
+ box-sizing: content-box;
+ z-index: 999;
+ user-select: text;
+ box-shadow: 5rpx 3rpx 1rpx -4rpx #c8c3c3;
+}
+
+
+
+.form-request {
+ display: block;
+ width: 100%;
+ color: #fff;
+ background-color: rgba(37, 0, 97, 0);
+ line-height: 50px;
+}
+
+.form-response {
+ position: relative;
+ width: 100%;
+ margin-top: 10px;
+ display: block;
+ margin-bottom: 10px;
+ color: #fff;
+ background-color: rgba(0, 72, 94, 0);
+ box-sizing: border-box;
+ min-height: 60px;
+}
+
+.form-response-user {
+ background-color: rgba(0, 72, 94, 0);
+ color: #fff;
+}
+
+.form-request-user {
+ background-color: rgba(37, 0, 97, 0);
+ color: #fff;
+}
+
+
+
+.bottom-box {
+ display: flex;
+ width: 100%;
+ display: absolute;
+ bottom: 100px;
+}
diff --git a/miniprogram/pages/blog/blog.js b/miniprogram/pages/blog/blog.js
index 97196bc7fd58a9516044f54b6f4edf1aa3b83fbc..75c5ead6b4435d70a2db84c317ba92f8a1de479c 100644
--- a/miniprogram/pages/blog/blog.js
+++ b/miniprogram/pages/blog/blog.js
@@ -99,17 +99,7 @@ Component({
* @param {*} title
*/
setArticleNode(articleStr,title){
- const markdownText = app.towxml(articleStr,'markdown',{
- theme:'light', //主题 dark 黑色,light白色,不填默认light
- events:{ //为元素绑定的事件方法
- tap:e => {
- console.log('tap',e);
- },
- change:e => {
- console.log('todo',e);
- }
- }
- });
+ const markdownText = app.changeMrkdownText(articleStr);
this.setData({
isLoading:false,
article:markdownText,
diff --git a/miniprogram/pages/future/future.js b/miniprogram/pages/future/future.js
index 0528621d9f3b61b02906726c03d118ae3b477b13..5d3859c9e84a3cfc0c1350bfc31e93cc926decbc 100644
--- a/miniprogram/pages/future/future.js
+++ b/miniprogram/pages/future/future.js
@@ -34,15 +34,11 @@ Component({
articleId: baseArticleId,
isShowOenAi: true,
baseUrl: 'https://yongma16.xyz/api/',
- baseCloudUrl: 'https://yongma16.xyz/cloudApi/',
- baseCloudAddRecordPath: 'openAiRecord/add',
- baseCloudUpdateUserPath: 'userModel/update',
- baseCloudgetUserPath: 'userModel/info',
- baseCloudGetRecordCountPath: 'openAiRecord/count',
+ baseCloudUrl: app.remoteConfig.baseCloudUrl,
path: 'article/blog/',
currentUserInfo: {
nickName: '',
- avatarUrl: ''
+ avatarUrl: '',
},
aiConfig: {
avatarUrl: 'https://yongma16.xyz/staticFile/common/img/aiTop.jpg',
@@ -177,8 +173,10 @@ Component({
wx_open_id: wxOpenId
}
const thisBack = this
+ const baseCloudUrl = this.data.baseCloudUrl
+ const baseInfoUrl = 'wechat/userinfo'
wx.request({
- url: this.data.baseCloudUrl + this.data.baseCloudgetUserPath,
+ url: baseCloudUrl + baseInfoUrl,
headers: headers,
data: params,
method: 'POST',
@@ -188,8 +186,8 @@ Component({
console.log('res.data__________',res.data)
thisBack.setData({
// 默认十条消息
- msgCount: res.data.data.data[0].send_msg_count || 10,
- isVip: res.data.data.data[0].is_vip || 0
+ msgCount: res.data.data.data.use_count || 10,
+ isVip: res.data.data.data.is_vip || 0
})
}
}),
@@ -198,45 +196,26 @@ Component({
}
})
},
- // 更新用户使用信息
- updateUserInfo() {
- const headers = { 'Content-Type': 'application/json;charset=UTF-8' }
- const openId = wx.getStorageSync('currentOpenid')
- const wxOpenId = openId && openId.openid
- const params = {
- wx_open_id: wxOpenId,
- send_msg_count: this.data.msgCount
- }
- const thisBack = this
- wx.request({
- url: this.data.baseCloudUrl + this.data.baseCloudUpdateUserPath,
- headers: headers,
- data: params,
- method: 'PUT',
- success: (res => {
- console.log('cloud res update', res)
- }),
- fail: r => {
- console.log('cloud r', r)
- }
- })
- },
+ // 更新用户使用信息 这个过程koa处理
// 获取用户使用次数
getUserReadCount() {
const headers = { 'Content-Type': 'application/json;charset=UTF-8' }
const openId = wx.getStorageSync('currentOpenid')
const wxOpenId = openId && openId.openid
const params = {
- wx_open_id: wxOpenId
+ wx_openid: wxOpenId
}
const thisBack = this
+ const baseCloudUrl = this.data.baseCloudUrl
+ const baseInfoUrl = 'wechat/count'
wx.request({
- url: this.data.baseCloudUrl + this.data.baseCloudGetRecordCountPath,
+ url: baseCloudUrl + baseInfoUrl,
headers: headers,
data: params,
method: 'POST',
success: (res => {
console.log('cloud res count', res)
+ console.log('res.data.data.use_count',res.data.data.use_count)
if (res.data.code === 0) {
// 0
thisBack.setData({
@@ -244,11 +223,11 @@ Component({
})
} else {
thisBack.setData({
- msgCount: res.data.data[0].send_msg_count
+ msgCount: res.data.data.use_count
})
}
// 更新用户
- thisBack.updateUserInfo()
+ // thisBack.updateUserInfo()
}),
fail: r => {
console.log('cloud r', r)
@@ -268,10 +247,12 @@ Component({
const headers = { 'Content-Type': 'application/json;charset=UTF-8' }
const openId = wx.getStorageSync('currentOpenid')
const wxOpenId = openId && openId.openid
- params.wx_open_id = wxOpenId
+ params.wx_openid = wxOpenId
const thisBack=this
+ const baseCloudUrl = this.data.baseCloudUrl
+ const baseInfoUrl = 'wechat/addcontent'
wx.request({
- url: this.data.baseCloudUrl + this.data.baseCloudAddRecordPath,
+ url: baseCloudUrl + baseInfoUrl,
headers: headers,
data: params,
method: 'POST',
@@ -499,10 +480,8 @@ Component({
resolve(res)
setTimeout(() => {
thisBack.createOpenRecord({
- wx_name: thisBack.data.currentUserInfo.nickName,
- wx_img: thisBack.data.currentUserInfo.avatarUrl,
- search_text: params.text,
- search_response: answer
+ question_content: params.text,
+ anwser_content: answer
})
}, 10)
console.log('thisBack.data.chatObjConfig.option', thisBack.data.chatObjConfig.option)
diff --git a/miniprogram/pages/future/future.wxss b/miniprogram/pages/future/future.wxss
index 638d37ca5b4223aa222663733c7559f96afc01d0..cbb177273de6f38ce123328a53b3796798ce591a 100644
--- a/miniprogram/pages/future/future.wxss
+++ b/miniprogram/pages/future/future.wxss
@@ -86,7 +86,7 @@ button {
color: rgb(255, 255, 255);
background: rgb(218, 218, 218);
margin: 5px auto;
- box-shadow:inset 0 1rpx 2rpx 1rpx rgba(0,0,0,0.2);
+ box-shadow: inset 0 1rpx 2rpx 1rpx rgba(0, 0, 0, 0.2);
}
.header-box {
@@ -183,7 +183,7 @@ button {
.container-box-article {
position: relative;
- padding-top:0px;
+ padding-top: 0px;
width: 100%;
height: calc(100vh - 88px);
box-shadow: inset 5px 5px #262626;
@@ -275,10 +275,12 @@ button {
border-left: 12px solid rgb(255, 255, 255);
box-shadow: 0rpx 0rpx 0rpx 0rpx #c8c3c3;
}
-.clear-paste-btn{
- width:70%;
+
+.clear-paste-btn {
+ width: 70%;
display: flex;
}
+
.submit-input {
box-shadow: 0 2rpx 5rpx 5rpx #c8c3c3;
width: 70%;
@@ -294,23 +296,24 @@ button {
/* padding-left: 5px; */
color: rgb(0, 114, 221);
}
-.send-btn::after{
+
+.send-btn::after {
position: absolute;
- left:0;
- top:0;
+ left: 0;
+ top: 0;
width: 100px;
height: 100%;
- background-color: rgba(255, 255, 255, .8);
+ background-color: rgba(255, 255, 255, .8);
}
-.up-down-btn{
- width:30%;
+.up-down-btn {
+ width: 30%;
}
.send-btn {
box-shadow: 0 2rpx 5rpx 5rpx #c8c3c3;
width: 30%;
- background-color:rgba(16, 116, 187);
+ background-color: rgba(16, 116, 187);
height: 100px;
line-height: 100px;
/* border-radius: 10px 0 0 10px; */
@@ -352,7 +355,7 @@ button {
box-sizing: content-box;
z-index: 999;
user-select: text;
- box-shadow:5rpx 3rpx 1rpx -4rpx #c8c3c3;
+ box-shadow: 5rpx 3rpx 1rpx -4rpx #c8c3c3;
}
.form-response-box-poly {
diff --git a/miniprogram/pages/index/index.js b/miniprogram/pages/index/index.js
index dffec8588c5fa67a3ef82ed1e884d11637ffb484..0cdf9ba9f98f653d8fa28f6dd0ab3167ee7c6512 100644
--- a/miniprogram/pages/index/index.js
+++ b/miniprogram/pages/index/index.js
@@ -4,7 +4,10 @@ const app = getApp()
Page({
data: {
baseUrl: app.remoteConfig.baseUrl,
+ baseCloudUrl: app.remoteConfig.baseCloudUrl,
baseLoginCloudPath: 'userModel/register',
+ botBtnTitle: "图片生成",
+ shopBtnTitle: '虚拟资产',
detailInfo: '关于:code笔记',
title: "yma16博客",
userImageUrl: "https://yongma16.xyz/staticFile/common/img/aiTop.jpg",
@@ -18,7 +21,9 @@ Page({
hasUserInfo: false,
isloading: true,
isOldVersion: false,
- isShowBottom: true
+ isShowBottom: true,
+ loginErrorTitle: '',
+ loginErrorContent: ''
},
getUserInfoBtn: function (info) {
wx.showLoading({
@@ -26,7 +31,10 @@ Page({
});
console.log('userinfo', info)
if (info && info.detail) {
- const rowData = info.detail.rawData ? JSON.parse(info.detail.rawData) : { nickName: '未授权用户', avatarUrl: '' }
+ const rowData = info.detail.rawData ? JSON.parse(info.detail.rawData) : {
+ nickName: '未授权用户',
+ avatarUrl: ''
+ }
this.setData({
userImageUrl: rowData.avatarUrl,
userName: rowData.nickName,
@@ -38,16 +46,50 @@ Page({
wx.hideLoading();
},
bindKeyInput(e) {
- const { value } = e.detail
+ const {
+ value
+ } = e.detail
console.log('val', value)
this.setData({
userName: value
})
},
+ clickBotBtn() {
+ wx.navigateTo({
+ url: '/pages/aiBot/aiBot'
+ })
+ },
+ // 进入虚拟资产
+ clickShopBtn() {
+ console.log('跳转')
+ // const thisBack = this
+ wx.navigateTo({
+ url: '/pages/shop/shop',
+ // events: {
+ // // 为指定事件添加一个监听器,获取被打开页面传送到当前页面的数据
+ // acceptDataFromOpenedPage: function (data) {
+ // console.log('acceptDataFromOpenedPage data', data)
+ // },
+ // someEvent: function (data) {
+ // console.log('someEvent data', data)
+ // }
+ // },
+ // success: function (res) {
+ // console.log('res jump', res)
+ // // 通过 eventChannel 向被打开页面传送数据
+ // res.eventChannel.emit('setHomePageData', {
+ // userInfo: thisBack.data.userInfo,
+ // isShowBottom: thisBack.data.isShowBottom
+ // })
+ // }
+ })
+ },
// 头像选择
onChooseAvatar(e) {
console.log('e', e)
- const { avatarUrl } = e.detail
+ const {
+ avatarUrl
+ } = e.detail
this.setData({
userImageUrl: avatarUrl,
})
@@ -101,14 +143,17 @@ Page({
loginSpringCloud() {
const openId = wx.getStorageSync('currentOpenid')
const wxOpenId = openId && openId.openid
- const headers = { 'Content-Type': 'application/json;charset=UTF-8' }
+ const headers = {
+ 'Content-Type': 'application/json;charset=UTF-8'
+ }
const params = {
- wx_open_id: wxOpenId,
+ wx_openid: wxOpenId,
wx_name: this.data.userName,
wx_img: this.data.userImageUrl
}
- const baseCloudUrl = 'https://yongma16.xyz/cloudApi/'
- const baseLoginCloudPath = 'userModel/register'
+ const baseCloudUrl = this.data.baseCloudUrl
+ const baseLoginCloudPath = 'wechat/register'
+ console.log('注册', params)
wx.request({
url: baseCloudUrl + baseLoginCloudPath,
headers: headers,
@@ -200,8 +245,10 @@ Page({
})
},
onLoad: function (options) {
+ console.log('index page')
console.log('option', options)
const authorPageConfig = app.wxProgramConfig.authorPageConfig
+ console.log('authorPageConfig', authorPageConfig)
this.setData({
detailInfo: authorPageConfig.detailInfo,
title: authorPageConfig.title,
@@ -213,6 +260,7 @@ Page({
designPlaceholder: authorPageConfig.designPlaceholder,
isOldVersion: authorPageConfig.isOldVersion,
joinTitle: authorPageConfig.joinTitle,
+ shopBtnTitle: authorPageConfig.shopBtnTitle,
isShowBottom: authorPageConfig.isShowBottom,
loginErrorTitle: authorPageConfig.loginErrorTitle,
loginErrorContent: authorPageConfig.loginErrorContent
@@ -247,4 +295,4 @@ Page({
onResize: function () {
// 页面尺寸变化时执行
}
-});
+});
\ No newline at end of file
diff --git a/miniprogram/pages/index/index.wxml b/miniprogram/pages/index/index.wxml
index c966249d9a908a3253666b2d983e14f5a884ecd8..71d0c464f2cb84874d0272b8116c64f8e244eb90 100644
--- a/miniprogram/pages/index/index.wxml
+++ b/miniprogram/pages/index/index.wxml
@@ -19,8 +19,8 @@
-
-
+
+
@@ -35,6 +35,12 @@
+
+
+
+
diff --git a/miniprogram/pages/index/index.wxss b/miniprogram/pages/index/index.wxss
index c6fc4b7ec0299c832dca411941f1c34eff97c412..2a17c18bde0b760bbf3d4307b24a1312d41c33c7 100644
--- a/miniprogram/pages/index/index.wxss
+++ b/miniprogram/pages/index/index.wxss
@@ -21,9 +21,7 @@ page {
}
.login-container{
- position: absolute;
- top:50%;
- transform: translateY(50%);
+ position: relative;
}
.code-container{
@@ -34,6 +32,22 @@ page {
.user-login {
+ margin-top: 10px;
+ width:120px !important;
+ color: #fff !important;
+ border-color: #fff !important;
+}
+
+.shop-btn{
+ margin-top: 160px;
+ width:120px !important;
+ color: #fff !important;
+ border-color: #fff !important;
+}
+
+
+.bot-btn{
+ margin-top: 120px;
width:120px !important;
color: #fff !important;
border-color: #fff !important;
@@ -49,14 +63,14 @@ page {
.user-image-box {
width: 200px;
- height: 140px;
+ height: 80px;
text-align: center;
align-items: center;
}
.user-image {
- width: 100px;
- height: 100px;
+ width: 30px;
+ height: 30px;
border-radius: 50%;
border: 2px solid #fff;
}
diff --git a/miniprogram/pages/shop/shop.js b/miniprogram/pages/shop/shop.js
new file mode 100644
index 0000000000000000000000000000000000000000..dee2713a47f1d4e2cebc247e31ec6c0886e0df79
--- /dev/null
+++ b/miniprogram/pages/shop/shop.js
@@ -0,0 +1,147 @@
+// pages/shop.js
+const app = getApp();
+Page({
+
+ /**
+ * 页面的初始数据
+ */
+ data: {
+ password: app.remoteConfig.cloudPwd || "U2FsdGVkX1+jfEkF2OXTQ5iIG4mrYc5/TLOiIntyENU=",
+ username: app.remoteConfig.cloudEmail || "1575057249@qq.com",
+ baseCloudUrl: app.remoteConfig.baseCloudUrl,
+ token: '',
+ name: '',
+ page: 1,
+ pageSize: 99,
+ productList: []
+ },
+
+ getUserToken() {
+ const that = this
+ wx.showLoading({
+ title: 'gen token loading',
+ });
+ wx.request({
+ url: this.data.baseCloudUrl + 'token/gen',
+ method: 'POST',
+ data: {
+ username: this.data.username,
+ password: this.data.password
+ },
+ success: (res => {
+ that.setData({
+ token: res.data.token
+ })
+ wx.hideLoading()
+ that.getProductList()
+ }),
+ fail: r => {
+ console.log('cloud r', r)
+ wx.hideLoading()
+ }
+ })
+ },
+ previewImage(e){
+ console.log('click png',e)
+ const url=e.target.dataset.url
+ wx.previewImage({
+ current: url, // 当前显示图片的http链接
+ urls: [url] // 需要预览的图片http链接列表
+ })
+ },
+
+ getRenderSrc(id) {
+ return `${this.data.baseCloudUrl}media/render?id=${id}`
+ },
+ getProductList() {
+ const that = this
+ wx.showLoading({
+ title: 'get list loading',
+ });
+ wx.request({
+ url: this.data.baseCloudUrl + '/product/list',
+ method: 'POST',
+ header: {
+ Authorization: `bearer ${this.data.token}`
+ },
+ data: {
+ name: '',
+ page: this.data.page,
+ pageSize: this.data.pageSize,
+ },
+ success: (res => {
+ that.setData({
+ productList: res.data.data.map(item => {
+ return {
+ ...item,
+ imgSrc: item.img_id?that.getRenderSrc(item.img_id):'',
+ mvSrc: item.mov_id?that.getRenderSrc(item.mov_id):'',
+ mode: 'scaleToFill',
+ }
+ })
+ })
+ wx.hideLoading()
+ }),
+ fail: r => {
+ console.log('cloud r', r)
+ wx.hideLoading()
+ }
+ })
+ },
+
+ /**
+ * 生命周期函数--监听页面加载
+ */
+ onLoad(options) {
+ this.getUserToken()
+ },
+
+ /**
+ * 生命周期函数--监听页面初次渲染完成
+ */
+ onReady() {
+
+ },
+
+ /**
+ * 生命周期函数--监听页面显示
+ */
+ onShow() {
+
+ },
+
+ /**
+ * 生命周期函数--监听页面隐藏
+ */
+ onHide() {
+
+ },
+
+ /**
+ * 生命周期函数--监听页面卸载
+ */
+ onUnload() {
+
+ },
+
+ /**
+ * 页面相关事件处理函数--监听用户下拉动作
+ */
+ onPullDownRefresh() {
+
+ },
+
+ /**
+ * 页面上拉触底事件的处理函数
+ */
+ onReachBottom() {
+
+ },
+
+ /**
+ * 用户点击右上角分享
+ */
+ onShareAppMessage() {
+
+ }
+})
\ No newline at end of file
diff --git a/miniprogram/pages/shop/shop.json b/miniprogram/pages/shop/shop.json
new file mode 100644
index 0000000000000000000000000000000000000000..3928faa4c3cd47c8210724f4ed82378eeaff71df
--- /dev/null
+++ b/miniprogram/pages/shop/shop.json
@@ -0,0 +1,3 @@
+{
+ "usingComponents": {}
+}
\ No newline at end of file
diff --git a/miniprogram/pages/shop/shop.wxml b/miniprogram/pages/shop/shop.wxml
new file mode 100644
index 0000000000000000000000000000000000000000..f98363171b22ea286d3ca38a5ea941d846973386
--- /dev/null
+++ b/miniprogram/pages/shop/shop.wxml
@@ -0,0 +1,20 @@
+
+
+
+
+ {{item.title}}
+
+ {{item.description}}
+
+
+
+
+
+ {{item.content}}
+
+
+
+
\ No newline at end of file
diff --git a/miniprogram/pages/shop/shop.wxss b/miniprogram/pages/shop/shop.wxss
new file mode 100644
index 0000000000000000000000000000000000000000..54f13f383a2d3dfe30bb117adeb8a608f72383ef
--- /dev/null
+++ b/miniprogram/pages/shop/shop.wxss
@@ -0,0 +1,50 @@
+/* pages/shop.wxss */
+.list-box {
+ width: 100%;
+ height: 100%;
+ color: #262626;
+ padding: 10px;
+
+}
+
+.container {
+
+ padding: 0;
+ margin: 0;
+ color: #333333;
+ background: #262626;
+}
+.list-item{
+ border:1px solid #dcdcdc;
+ margin: 5px;
+ padding: 2px;
+ text-indent: 12px;
+ width: 90%;
+ height: 250px;
+ background: #ffffff;
+ border-radius: 10px;
+ box-shadow: 0 10px 15px rgba(255,255,255,.6);
+}
+
+.item-title {
+ font-weight: bold;
+}
+
+
+
+.item-content {
+ color: #333333;
+}
+
+.item-box {
+ padding: 5px 0;
+ margin:2px 0;
+ width: 100%;
+ text-align: center;
+ text-indent: 0;
+}
+
+.item-img{
+ max-height: 150px;
+ width: 80%;
+}
\ No newline at end of file
diff --git a/package.json b/package.json
new file mode 100644
index 0000000000000000000000000000000000000000..dce21b22a6dd61063ae4917cc60e90b0a09d54be
--- /dev/null
+++ b/package.json
@@ -0,0 +1,15 @@
+{
+ "name": "yma16_program",
+ "version": "1.0.0",
+ "description": "- [云开发文档](https://developers.weixin.qq.com/miniprogram/dev/wxcloud/basis/getting-started.html) ### 云开发小程序",
+ "main": ".eslintrc.js",
+ "scripts": {
+ "test": "echo \"Error: no test specified\" && exit 1"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git@gitcode.net:qq_38870145/yma16_miniprogram.git"
+ },
+ "author": "yma16",
+ "license": "ISC"
+}
diff --git a/project.config.json b/project.config.json
index 9257851a2f66f5604885c6a2cd0aeff086a13b4b..049b109958c70694f170a510b6bb500de43c4568 100644
--- a/project.config.json
+++ b/project.config.json
@@ -1,9 +1,5 @@
{
"description": "项目配置文件",
- "packOptions": {
- "ignore": [],
- "include": []
- },
"setting": {
"urlCheck": true,
"es6": true,
@@ -24,8 +20,6 @@
"compileHotReLoad": true,
"lazyloadPlaceholderEnable": false,
"useMultiFrameRuntime": true,
- "useApiHook": true,
- "useApiHostProcess": true,
"babelSetting": {
"ignore": [],
"disablePlugins": [],
@@ -41,12 +35,10 @@
"minifyWXML": true,
"showES6CompileOption": false,
"useCompilerPlugins": false,
- "condition": false
+ "condition": false,
+ "ignoreUploadUnusedFiles": true
},
"compileType": "miniprogram",
- "libVersion": "2.27.0",
- "appid": "wx373f33f993c688d1",
- "projectname": "yma16_program",
"miniprogramRoot": "miniprogram/",
"cloudfunctionRoot": "cloudfunctions/",
"cloudfunctionTemplateRoot": "cloudfunctionTemplate/",
@@ -75,5 +67,10 @@
"editorSetting": {
"tabIndent": "insertSpaces",
"tabSize": 4
- }
+ },
+ "packOptions": {
+ "ignore": [],
+ "include": []
+ },
+ "appid": "wx373f33f993c688d1"
}
\ No newline at end of file
diff --git a/project.private.config.json b/project.private.config.json
index 56aff12cb906023cc15ae771991b01d991e480bf..5bda77577acf4b0ea48fd74ddd159d075e41c3f9 100644
--- a/project.private.config.json
+++ b/project.private.config.json
@@ -1,13 +1,14 @@
{
"setting": {
- "compileHotReLoad": true
+ "compileHotReLoad": true,
+ "urlCheck": false
},
"condition": {
"miniprogram": {
"list": [
{
- "name": "pages/getOpenId/index",
- "pathName": "pages/getOpenId/index",
+ "name": "yma16博客",
+ "pathName": "pages/index/index",
"query": "",
"scene": null
}
@@ -15,5 +16,6 @@
}
},
"description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
- "projectname": "yma16_program"
+ "projectname": "yma16_program",
+ "libVersion": "2.25.3"
}
\ No newline at end of file