\u6700\u8fd1\u505a\u4e86\u4e00\u4e2a\u6821\u56ed\u62cd\u5356\u5c0f\u7a0b\u5e8f\uff0c\u60f3\u5728\u91cc\u9762\u6dfb\u52a0\u4e00\u4e2a\u7c7b\u4f3c\u6821\u56ed\u5708\u529f\u80fd\uff0c\u73b0\u5728\u6765\u4e00\u6b65\u4e00\u6b65\u5b9e\u73b0\u3002<\/p> \n
\u4e00\u3001\u8bbe\u8ba1\u6240\u9700\u8981\u7684\u8868<\/h1> \n 1\u3001\u6587\u7ae0\u8868<\/h2> \n
\u6587\u7ae0\u8868\u5f88\u7b80\u5355\uff0c\u5c31\u7c7b\u4f3c\u670b\u53cb\u5708\uff0c\u4e00\u4e2a\u6587\u5b57\u5185\u5bb9\uff0c\u4e00\u4e2a\u56fe\u7247\u6570\u7ec4<\/p> \n
<\/p> \n
<\/p> \n
\u4e8c\u3001\u53d1\u5e03\u52a8\u6001<\/h1> \n 1\u3001\u6587\u672c\u533a<\/h2> \n
\u5149\u6807\u6709\u70b9\u95ee\u9898\uff0c\u56de\u8f66\u6362\u884c\u65f6\u5149\u6807\u548c\u6587\u5b57\u88ab\u57cb\u5728\u4e0b\u9762\u4e86<\/p> \n
<\/p> \n
\u89e3\u51b3\uff0c\u7ed9textarea\u8bbe\u7f6e\u4e00\u4e2a\u6700\u5927\u9ad8\u5ea6\uff0cmax-length,\u628ascroll-view\u6539\u4e3aview \uff0c\u56e0\u4e3atextarea\u672c\u8eab\u81ea\u5e26\u6eda\u52a8<\/p> \n
<\/p> \n
2\u3001\u6700\u7ec8\u53d1\u8868\u52a8\u6001\u6548\u679c<\/h2> \n
<\/p> \n
<\/p> \n
3\u3001\u53d1\u5e03\u52a8\u6001\u4ee3\u7801<\/h2> \n 1\u3001publisherArticle.wxml<\/h3> \n \n <view class="main">\n <!--\u6587\u5b57\u533a-->\n <view class="text" >\n <textarea fixed="true" auto-height placeholder="\u8fd9\u4e00\u523b\u7684\u60f3\u6cd5..." bindinput="setText" style="margin: 10rpx;width: 96%;max-height: 90%;"\/> \n <\/view>\n <!--\u56fe\u7247\u533a-->\n <view class="img">\n <block wx:for="{{selectImgs}}" wx:key="index">\n <image src="{{item}}" style="height: 220rpx;width: 220rpx;margin: 10rpx;"><\/image>\n <\/block>\n <image wx:if="{{selectImgs.length != 9}}" src="\/image\/addImg.png" bindtap="selectImg" style="height: 80rpx;width: 80rpx;padding: 70rpx;background-color: rgb(241, 236, 236);margin-top: 10rpx;"><\/image>\n <\/view>\n <view class="publish" bindtap="publish">\u53d1\u8868<\/view>\n<\/view>\n<\/pre> \n <\/div> \n 2\u3001publisherArticle.wxss<\/h3> \n \n .main{\n position: fixed;\n top: 10rpx;\n bottom: 10rpx;\n left: 0rpx;\n right: 0rpx;\n z-index: 0;\n}\n.text{\n position: fixed;\n top: 20rpx;\n left: 10rpx;\n right: 10rpx;\n height: 23%;\n background-color: white;\n border-radius: 10rpx;\n z-index: 1;\n}\n.img{\n position: fixed;\n display: flex;\n flex-wrap: wrap;\n top: 23%;\n left: 10rpx;\n right: 10rpx;\n bottom: 15%;\n background-color: white;\n border-radius: 10rpx;\n z-index: 1;\n}\n.publish{\n position: fixed;\n z-index: 1;\n top: 88%;\n width: 11%;\n left: 40%;\n background-color: rgb(8, 88, 32);\n color: white;\n font-size: 40rpx;\n border-radius: 30px;\n padding: 10rpx 30rpx;\n box-shadow: 2px 2px 10px rgb(16, 46, 33);\n}\n<\/pre> \n <\/div> \n 3\u3001publishArticle.js<\/h3> \n \n Page({\n data: {\n selectImgs: null,\n text: '',\n uploadImgs: []\n },\n selectImg(){\n wx.chooseImage({\n count: 8,\n success: (res) => {\n this.setData({\n selectImgs: res.tempFilePaths\n })\n }\n })\n },\n setText(e){\n let text = e.detail.value\n console.log(text)\n this.setData({\n text: text\n })\n },\n \/\/\u53d1\u8868\u52a8\u6001\n publish(){\n this.uploadImages().then((resolve, reject) => {\n wx.showLoading({\n title: '\u53d1\u5e03\u4e2d'\n })\n setTimeout(() => {}, 500)\n let imagesUrl = this.data.uploadImgs \/\/\u4e91\u5b58\u50a8\u7684\u56fe\u7247\u5217\u8868\n let text = this.data.text\n wx.cloud.database().collection('article').add({\n data: {\n content: text,\n imagesUrl: imagesUrl\n },\n success: (res) => {\n wx.hideLoading({\n success: (res) => {\n wx.showToast({\n title: '\u53d1\u8868\u6210\u529f',\n })\n wx.navigateBack({\n delta: 1,\n })\n },\n })\n }\n })\n })\n },\n \/\/\u4e0a\u4f20\u56fe\u7247\u5230\u4e91\u5b58\u50a8\n uploadImages() {\n let _this = this\n return new Promise(function (resolve, reject) {\n function upload(index) {\n var picnum = index+1\n wx.showLoading({\n title: '\u4e0a\u4f20\u7b2c' + picnum + '\u5f20\u56fe\u7247'\n })\n wx.cloud.uploadFile({\n cloudPath: 'articleImgs\/' + new Date().getTime() + '_' + Math.floor(Math.random() * 1000) + '.jpg', \/\/\u7ed9\u56fe\u7247\u547d\u540d\n filePath: _this.data.selectImgs[index], \/\/\u672c\u5730\u56fe\u7247\u8def\u5f84\n success: (res) => {\n _this.data.uploadImgs[index] = res.fileID\n wx.hideLoading({\n success: (res) => {},\n })\n \/\/\u5224\u65ad\u662f\u5426\u5168\u90e8\u4e0a\u4f20\n if (_this.data.selectImgs.length - 1 <= index) {\n console.log('\u5df2\u5168\u90e8\u4e0a\u4f20')\n resolve('success')\n return\n } else {\n conso","orderid":"0","title":"\u3010\u5c0f\u7a0b\u5e8f\u3011\u5b9e\u73b0\u53d1\u52a8\u6001\u529f\u80fd(\u4e00)","smalltitle":"","mid":"0","fname":"\u5176\u5b83","special_id":"0","bak_id":"0","info":"0","hits":"116","pages":"2","comments":"0","posttime":"2023-07-23 13:25:42","list":"1690089942","username":"admin","author":"","copyfrom":"","copyfromurl":"","titlecolor":"","fonttype":"0","titleicon":"0","picurl":"https:\/\/www.cppentry.com\/upload_files\/","ispic":"0","yz":"1","yzer":"","yztime":"0","levels":"0","levelstime":"0","keywords":"\u7a0b\u5e8f<\/A>","jumpurl":"","iframeurl":"","style":"","template":"a:3:{s:4:\"head\";s:0:\"\";s:4:\"foot\";s:0:\"\";s:8:\"bencandy\";s:0:\"\";}","target":"0","ip":"119.59.235.169","lastfid":"0","money":"0","buyuser":"","passwd":"","allowdown":"","allowview":"","editer":"","edittime":"0","begintime":"0","endtime":"0","description":"\u3010\u5c0f\u7a0b\u5e8f\u3011\u5b9e\u73b0\u53d1\u52a8\u6001\u529f\u80fd","lastview":"1714785508","digg_num":"0","digg_time":"0","forbidcomment":"0","ifvote":"0","heart":"","htmlname":"","city_id":"0"},"page":"1"}
<view class="main">\n <!--\u6587\u5b57\u533a-->\n <view class="text" >\n <textarea fixed="true" auto-height placeholder="\u8fd9\u4e00\u523b\u7684\u60f3\u6cd5..." bindinput="setText" style="margin: 10rpx;width: 96%;max-height: 90%;"\/> \n <\/view>\n <!--\u56fe\u7247\u533a-->\n <view class="img">\n <block wx:for="{{selectImgs}}" wx:key="index">\n <image src="{{item}}" style="height: 220rpx;width: 220rpx;margin: 10rpx;"><\/image>\n <\/block>\n <image wx:if="{{selectImgs.length != 9}}" src="\/image\/addImg.png" bindtap="selectImg" style="height: 80rpx;width: 80rpx;padding: 70rpx;background-color: rgb(241, 236, 236);margin-top: 10rpx;"><\/image>\n <\/view>\n <view class="publish" bindtap="publish">\u53d1\u8868<\/view>\n<\/view>\n<\/pre> \n <\/div> \n2\u3001publisherArticle.wxss<\/h3> \n
\n.main{\n position: fixed;\n top: 10rpx;\n bottom: 10rpx;\n left: 0rpx;\n right: 0rpx;\n z-index: 0;\n}\n.text{\n position: fixed;\n top: 20rpx;\n left: 10rpx;\n right: 10rpx;\n height: 23%;\n background-color: white;\n border-radius: 10rpx;\n z-index: 1;\n}\n.img{\n position: fixed;\n display: flex;\n flex-wrap: wrap;\n top: 23%;\n left: 10rpx;\n right: 10rpx;\n bottom: 15%;\n background-color: white;\n border-radius: 10rpx;\n z-index: 1;\n}\n.publish{\n position: fixed;\n z-index: 1;\n top: 88%;\n width: 11%;\n left: 40%;\n background-color: rgb(8, 88, 32);\n color: white;\n font-size: 40rpx;\n border-radius: 30px;\n padding: 10rpx 30rpx;\n box-shadow: 2px 2px 10px rgb(16, 46, 33);\n}\n<\/pre> \n <\/div> \n3\u3001publishArticle.js<\/h3> \n
\nPage({\n data: {\n selectImgs: null,\n text: '',\n uploadImgs: []\n },\n selectImg(){\n wx.chooseImage({\n count: 8,\n success: (res) => {\n this.setData({\n selectImgs: res.tempFilePaths\n })\n }\n })\n },\n setText(e){\n let text = e.detail.value\n console.log(text)\n this.setData({\n text: text\n })\n },\n \/\/\u53d1\u8868\u52a8\u6001\n publish(){\n this.uploadImages().then((resolve, reject) => {\n wx.showLoading({\n title: '\u53d1\u5e03\u4e2d'\n })\n setTimeout(() => {}, 500)\n let imagesUrl = this.data.uploadImgs \/\/\u4e91\u5b58\u50a8\u7684\u56fe\u7247\u5217\u8868\n let text = this.data.text\n wx.cloud.database().collection('article').add({\n data: {\n content: text,\n imagesUrl: imagesUrl\n },\n success: (res) => {\n wx.hideLoading({\n success: (res) => {\n wx.showToast({\n title: '\u53d1\u8868\u6210\u529f',\n })\n wx.navigateBack({\n delta: 1,\n })\n },\n })\n }\n })\n })\n },\n \/\/\u4e0a\u4f20\u56fe\u7247\u5230\u4e91\u5b58\u50a8\n uploadImages() {\n let _this = this\n return new Promise(function (resolve, reject) {\n function upload(index) {\n var picnum = index+1\n wx.showLoading({\n title: '\u4e0a\u4f20\u7b2c' + picnum + '\u5f20\u56fe\u7247'\n })\n wx.cloud.uploadFile({\n cloudPath: 'articleImgs\/' + new Date().getTime() + '_' + Math.floor(Math.random() * 1000) + '.jpg', \/\/\u7ed9\u56fe\u7247\u547d\u540d\n filePath: _this.data.selectImgs[index], \/\/\u672c\u5730\u56fe\u7247\u8def\u5f84\n success: (res) => {\n _this.data.uploadImgs[index] = res.fileID\n wx.hideLoading({\n success: (res) => {},\n })\n \/\/\u5224\u65ad\u662f\u5426\u5168\u90e8\u4e0a\u4f20\n if (_this.data.selectImgs.length - 1 <= index) {\n console.log('\u5df2\u5168\u90e8\u4e0a\u4f20')\n resolve('success')\n return\n } else {\n conso","orderid":"0","title":"\u3010\u5c0f\u7a0b\u5e8f\u3011\u5b9e\u73b0\u53d1\u52a8\u6001\u529f\u80fd(\u4e00)","smalltitle":"","mid":"0","fname":"\u5176\u5b83","special_id":"0","bak_id":"0","info":"0","hits":"116","pages":"2","comments":"0","posttime":"2023-07-23 13:25:42","list":"1690089942","username":"admin","author":"","copyfrom":"","copyfromurl":"","titlecolor":"","fonttype":"0","titleicon":"0","picurl":"https:\/\/www.cppentry.com\/upload_files\/","ispic":"0","yz":"1","yzer":"","yztime":"0","levels":"0","levelstime":"0","keywords":"\u7a0b\u5e8f<\/A>","jumpurl":"","iframeurl":"","style":"","template":"a:3:{s:4:\"head\";s:0:\"\";s:4:\"foot\";s:0:\"\";s:8:\"bencandy\";s:0:\"\";}","target":"0","ip":"119.59.235.169","lastfid":"0","money":"0","buyuser":"","passwd":"","allowdown":"","allowview":"","editer":"","edittime":"0","begintime":"0","endtime":"0","description":"\u3010\u5c0f\u7a0b\u5e8f\u3011\u5b9e\u73b0\u53d1\u52a8\u6001\u529f\u80fd","lastview":"1714785508","digg_num":"0","digg_time":"0","forbidcomment":"0","ifvote":"0","heart":"","htmlname":"","city_id":"0"},"page":"1"}