<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                寫作頁面布局 ~~~ <template> <view class="wrap"> <view class="write_title"> <input type="text" v-model="title" placeholder="請輸入標題" /> </view> <!-- 內容展示區 --> <view class="artList"> <block v-for="(item, index) in artList" :key="index"> <view class="item" v-if="item.type == 'image'"><image :src="item.content" :data-index="index" mode="widthFix" @tap="removeImg" /></view> <view class="item" v-if="item.type == 'text'"> <textarea :value="item.content" placeholder="" v-model="artList[index].content" /> <view :data-index="index" class="deleteText" @tap="deleteText">刪除</view> </view> </block> </view> <!-- 輸入區 --> <form @submit="submit"> <view class="inputArea"> <view class="addImg" @tap="addImg">+圖片</view> <view class="addText"> <textarea name="artText" maxlength="-1" v-model="inputContent" placeholder="請輸入文本" /> <button type="primary" form-type="submit">添加</button> </view> </view> </form> <!-- 選擇分類 --> <view class="art-cate"> <view>文章分類</view> <view class=""> <picker mode="selector" :range="caties" @change="cateChange"> <view>{{caties[currentCateIndex]}}</view> </picker> </view> </view> <!-- 提交按鈕 --> <view class="submitNow" v-if="artList.length > 0" @tap="submitNow">發布文章</view> </view> </template> <script> var _self, loginRes; var signModel = require('../../commons/sign.js'); export default { data() { return { title : '', artList : [], inputContent : "", needUploadImg : [], uploadIndex : 0, //分類 caties : ['點擊選擇'], currentCateIndex : 0, catiesFromApi : [], // 記錄真實選擇的api接口數據的分類id sedCateIndex : 0 }; }, onLoad : function() { _self = this; signModel.sign(this.apiServer); loginRes = this.checkLogin('../write/write', '2'); if(!loginRes){return false;} // 加載文章分類 uni.request({ url: this.apiServer+'category&m=index', method: 'GET', success: res => { if(res.data.status == 'ok'){ // 把數據格式整理為 picker 支持的格式 ['分類名', ...] var categories = res.data.data; for(var k in categories){ _self.caties.push(categories[k]); } // 記錄分類信息 _self.catiesFromApi = categories; } } }); }, methods:{ cateChange : function(e){ var sedIndex = e.detail.value; this.currentCateIndex = sedIndex; // 獲取選擇的分類名稱 if(sedIndex < 1){return ;} var cateName = this.caties[sedIndex]; for(var k in this.catiesFromApi){ if(cateName == this.catiesFromApi[k]){ this.sedCateIndex = k; break; } } this.currentCateIndex = sedIndex; }, removeImg : function(e){ var index = e.currentTarget.dataset.index; uni.showModal({ content:"確定要刪除此圖片嗎", title:'提示', success(e) { if (e.confirm) { _self.artList.splice(index, 1); } } }); }, deleteText : function(e){ var index = e.currentTarget.dataset.index; uni.showModal({ content:"確定要刪除嗎", title:'提示', success(e) { if (e.confirm) { _self.artList.splice(index, 1); } } }); }, submitNow : function(){ // 數據驗證 if(this.title.length < 2){uni.showToast({title:'請輸入標題', icon:"none"}); return ;} if(this.artList.length < 1){uni.showToast({title:'請填寫文章內容', icon:"none"}); return ;} if(this.sedCateIndex < 1){uni.showToast({title:'請選擇分類', icon:"none"}); return ;} // 上傳圖片 一次一個多次上傳 [ 遞歸函數 ] // 上傳完成后整體提交數據 // 首先整理一下需要上傳的圖片 // this.needUploadImg = [{tmpurl : 臨時地址, index : 數據索引}] this.needUploadImg = []; for(var i = 0; i < this.artList.length; i++){ if(this.artList[i].type == 'image'){ this.needUploadImg.push({"tmpurl" : this.artList[i].content , "indexID" : i}); } } this.uploadImg(); }, uploadImg : function(){ // 如果沒有圖片 或者已經上傳完成 則執行提交 if(this.needUploadImg.length < 1 || this.uploadIndex >= this.needUploadImg.length){ uni.showLoading({title:"正在提交"}); // 將信息整合后提交到服務器 var sign = uni.getStorageSync('sign'); uni.request({ url: this.apiServer + 'art&m=add', method: 'POST', header: {'content-type' : "application/x-www-form-urlencoded"}, data: { title : _self.title, content : JSON.stringify(_self.artList), uid : loginRes[0], random : loginRes[1], cate : _self.sedCateIndex, sign : sign }, success: res => { console.log(res); if(res.data.status == 'ok'){ uni.showToast({title:"提交成功", icon:"none"}); _self.artList = []; // 清空數據 signModel.sign(_self.apiServer); // 防止數據緩存 _self.currentCateIndex = 0; _self.sedCateIndex = 0; _self.needUploadImg = []; _self.title = ''; setTimeout(function(){ uni.switchTab({ url:'../my/my' }) }, 1000); }else{ uni.showToast({title:res.data.data, icon:"none"}); } }, fail: (res) => { }, complete: () => { } }); return ; } // 上傳圖片 uni.showLoading({title:"上傳圖片"}); var uploader = uni.uploadFile({ url : _self.apiServer+'uploadImg&m=index', filePath : _self.needUploadImg[_self.uploadIndex].tmpurl, name : 'file', success: (uploadFileRes) => { uploadFileRes = JSON.parse(uploadFileRes.data); if(uploadFileRes.status != 'ok'){ console.log(uploadFileRes); uni.showToast({title:"上傳圖片失敗,請重試!", icon:"none"}); return false; } // 將已經上傳的文件地址賦值給文章數據 var index = _self.needUploadImg[_self.uploadIndex].indexID; _self.artList[index].content = _self.staticServer + uploadFileRes.data; console.log(_self.artList); _self.uploadIndex ++; // 遞歸上傳 setTimeout(function(){_self.uploadImg();}, 1000); }, fail: () => { uni.showToast({title:"上傳圖片失敗,請重試!", icon:"none"}); } }) }, submit : function(res){ var content = res.detail.value.artText; if(content.length < 1){uni.showToast({title:"請輸入內容",icon:'none'}); return ;} this.artList.push({"type":"text", "content" : content}); this.inputContent = ''; }, addImg : function(){ uni.chooseImage({ count: 1, sizeType: ['compressed'], success: function(res) { _self.artList.push({"type":"image", "content" : res.tempFilePaths[0]}) } }) } } } </script> <style></style> ~~~ **editArt.vue 代碼** ~~~ <template> <view class="wrap"> <view class="write_title"> <input type="text" v-model="title" placeholder="請輸入標題" /> </view> <!-- 內容展示區 --> <view class="artList"> <block v-for="(item, index) in artList" :key="index"> <view class="item" v-if="item.type == 'image'"><image :src="item.content" :data-index="index" mode="widthFix" @tap="removeImg" /></view> <view class="item" v-if="item.type == 'text'"> <textarea :value="item.content" placeholder="" v-model="artList[index].content" /> <view :data-index="index" class="deleteText" @tap="deleteText">刪除</view> </view> </block> </view> <!-- 輸入區 --> <form @submit="submit"> <view class="inputArea"> <view class="addImg" @tap="addImg">+圖片</view> <view class="addText"> <textarea name="artText" maxlength="-1" v-model="inputContent" placeholder="請輸入文本" /> <button type="primary" form-type="submit">添加</button> </view> </view> </form> <!-- 選擇分類 --> <view class="art-cate"> <view>文章分類</view> <view class=""> <picker mode="selector" :range="caties" @change="cateChange"> <view>{{caties[currentCateIndex]}}</view> </picker> </view> </view> <!-- 提交按鈕 --> <view class="submitNow" v-if="artList.length > 0" @tap="submitNow">編輯文章</view> </view> </template> <script> var artId, loginRes, _self; var signModel = require('../../commons/sign.js'); export default { data() { return { title : '', artList : [], inputContent : "", needUploadImg : [], uploadIndex : 0, //分類 caties : ['點擊選擇'], currentCateIndex : 0, catiesFromApi : [], // 記錄真實選擇的api接口數據的分類id sedCateIndex : 0 }; }, onLoad :function(options){ artId = options.artId; _self = this; signModel.sign(this.apiServer); loginRes = this.checkLogin('../my/my', '2'); if(!loginRes){return false;} // 加載文章默認值 uni.request({ url: this.apiServer+'art&m=info&artid='+artId, method: 'GET', data: {}, success: res => { var art = res.data.data; // 文章內容轉換并展示 var artContent = art.art_content; artContent = JSON.parse(artContent); _self.artList = artContent; // 默認值賦值 this.title = art.art_title; // 加載文章分類并設置默認值 uni.request({ url: _self.apiServer+'category&m=index', method: 'GET', success: res => { if(res.data.status == 'ok'){ // 把數據格式整理為 picker 支持的格式 ['分類名', ...] var categories = res.data.data; for(var k in categories){ _self.caties.push(categories[k]); } // 記錄分類信息 _self.catiesFromApi = categories; // 獲取當前分類的默認值 _self.sedCateIndex = art.art_cate; // 對應的查找picker的默認值 var cateName = categories[art.art_cate]; for(var i = 0; i < _self.caties.length; i++){ if(cateName == _self.caties[i]){ _self.currentCateIndex = i; break; } } console.log(_self.currentCateIndex); } } }); } }); }, methods:{ submitNow : function(){ // 數據驗證 if(this.title.length < 2){uni.showToast({title:'請輸入標題', icon:"none"}); return ;} if(this.artList.length < 1){uni.showToast({title:'請填寫文章內容', icon:"none"}); return ;} if(this.sedCateIndex < 1){uni.showToast({title:'請選擇分類', icon:"none"}); return ;} // 上傳圖片 一次一個多次上傳 [ 遞歸函數 ] // 上傳完成后整體提交數據 // 首先整理一下需要上傳的圖片 // this.needUploadImg = [{tmpurl : 臨時地址, index : 數據索引}] this.needUploadImg = []; for(var i = 0; i < this.artList.length; i++){ if(this.artList[i].type == 'image'){ if(this.artList[i].content.indexOf('192.168.31.') == -1){ this.needUploadImg.push({"tmpurl" : this.artList[i].content , "indexID" : i}); } } } this.uploadImg(); }, uploadImg : function(){ // 如果沒有圖片 或者已經上傳完成 則執行提交 if(this.needUploadImg.length < 1 || this.uploadIndex >= this.needUploadImg.length){ uni.showLoading({title:"正在提交"}); // 將信息整合后提交到服務器 var sign = uni.getStorageSync('sign'); uni.request({ url: this.apiServer + 'art&m=edit&artid='+artId, method: 'POST', header: {'content-type' : "application/x-www-form-urlencoded"}, data: { title : _self.title, content : JSON.stringify(_self.artList), uid : loginRes[0], random : loginRes[1], cate : _self.sedCateIndex, sign : sign }, success: res => { if(res.data.status == 'ok'){ uni.showToast({title:"提交成功", icon:"none"}); setTimeout(function(){ uni.switchTab({ url:'../my/my' }) }, 1000); }else{ uni.showToast({title:res.data.data, icon:"none"}); } } }); return ; } // 上傳圖片 uni.showLoading({title:"上傳圖片"}); var uploader = uni.uploadFile({ url : _self.apiServer+'uploadImg&m=index', filePath : _self.needUploadImg[_self.uploadIndex].tmpurl, name : 'file', success: (uploadFileRes) => { uploadFileRes = JSON.parse(uploadFileRes.data); if(uploadFileRes.status != 'ok'){ console.log(uploadFileRes); uni.showToast({title:"上傳圖片失敗,請重試!", icon:"none"}); return false; } // 將已經上傳的文件地址賦值給文章數據 var index = _self.needUploadImg[_self.uploadIndex].indexID; _self.artList[index].content = _self.staticServer + uploadFileRes.data; console.log(_self.artList); _self.uploadIndex ++; // 遞歸上傳 setTimeout(function(){_self.uploadImg();}, 1000); }, fail: () => { uni.showToast({title:"上傳圖片失敗,請重試!", icon:"none"}); } }) }, cateChange : function(e){ var sedIndex = e.detail.value; this.currentCateIndex = sedIndex; // 獲取選擇的分類名稱 if(sedIndex < 1){return ;} var cateName = this.caties[sedIndex]; for(var i = 0; i < this.catiesFromApi.length; i++){ if(cateName == this.catiesFromApi[i].cate_name){ this.sedCateIndex = this.catiesFromApi[i].cate_id; break; } } this.currentCateIndex = sedIndex; console.log(this.sedCateIndex); }, removeImg : function(e){ console.log(e); var index = e.currentTarget.dataset.index; uni.showModal({ content:"確定要刪除此圖片嗎", title:'提示', success(e) { if (e.confirm) { _self.artList.splice(index, 1); } } }); }, deleteText : function(e){ var index = e.currentTarget.dataset.index; uni.showModal({ content:"確定要刪除嗎", title:'提示', success(e) { if (e.confirm) { _self.artList.splice(index, 1); } } }); }, submit : function(res){ var content = res.detail.value.artText; if(content.length < 1){uni.showToast({title:"請輸入內容",icon:'none'}); return ;} this.artList.push({"type":"text", "content" : content}); this.inputContent = ''; }, addImg : function(){ uni.chooseImage({ count: 1, sizeType: ['compressed'], success: function(res) { _self.artList.push({"type":"image", "content" : res.tempFilePaths[0]}) } }); } } } </script> <style> </style> ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看