From badf843f46f97d0abe1bdfe90d156f67a2044c70 Mon Sep 17 00:00:00 2001 From: "3075067877@qq.com" <3075067877@qq.com> Date: Tue, 9 Apr 2024 10:27:34 +0800 Subject: [PATCH] add miniapp-change-category --- src/manifest.json | 2 +- src/pages/login/login.vue | 2 +- .../popup-content/miniapp-change-category.vue | 869 +++++++++++++++++++++ .../popup-content/miniapp-change-jian-jie.vue | 434 ---------- .../popup-content/miniapp-change-name.vue | 8 +- .../popup-content/miniapp-change-signature.vue | 434 ++++++++++ src/subpackage/party/pages/index/index.vue | 2 +- src/subpackage/party/pages/miniapp/regist.vue | 126 ++- 8 files changed, 1396 insertions(+), 481 deletions(-) create mode 100644 src/subpackage/party/components/popup-content/miniapp-change-category.vue delete mode 100644 src/subpackage/party/components/popup-content/miniapp-change-jian-jie.vue create mode 100644 src/subpackage/party/components/popup-content/miniapp-change-signature.vue diff --git a/src/manifest.json b/src/manifest.json index d409cc9..f435c28 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -57,7 +57,7 @@ /* 微信小程序特有相关 */ "plugins": { "miniprogram-thirdparty-plugin": { - "version": "0.3.13", + "version": "0.3.12", "provider": "wxb8b928431b8c56d8", "export": "" }, diff --git a/src/pages/login/login.vue b/src/pages/login/login.vue index fbe6206..7c458a3 100644 --- a/src/pages/login/login.vue +++ b/src/pages/login/login.vue @@ -49,7 +49,7 @@ const uniGetSetting = util.promisify(uni.getSetting); const uniLogin = util.promisify(uni.login); const APPID = uni.getAccountInfoSync().miniProgram.appId; -const MiniprogramThirdpartyPlugin = requirePlugin('miniprogram-thirdparty-plugin') +// const MiniprogramThirdpartyPlugin = requirePlugin('miniprogram-thirdparty-plugin') export default { computed: { isProfile: _=> util.isProfile(), diff --git a/src/subpackage/party/components/popup-content/miniapp-change-category.vue b/src/subpackage/party/components/popup-content/miniapp-change-category.vue new file mode 100644 index 0000000..0b94209 --- /dev/null +++ b/src/subpackage/party/components/popup-content/miniapp-change-category.vue @@ -0,0 +1,869 @@ + + + + + \ No newline at end of file diff --git a/src/subpackage/party/components/popup-content/miniapp-change-jian-jie.vue b/src/subpackage/party/components/popup-content/miniapp-change-jian-jie.vue deleted file mode 100644 index af4e9db..0000000 --- a/src/subpackage/party/components/popup-content/miniapp-change-jian-jie.vue +++ /dev/null @@ -1,434 +0,0 @@ - - - - - \ No newline at end of file diff --git a/src/subpackage/party/components/popup-content/miniapp-change-name.vue b/src/subpackage/party/components/popup-content/miniapp-change-name.vue index bac1607..8f12b14 100644 --- a/src/subpackage/party/components/popup-content/miniapp-change-name.vue +++ b/src/subpackage/party/components/popup-content/miniapp-change-name.vue @@ -32,8 +32,8 @@ - - {{checkNameRes.message||checkNameRes.data.wording}} + + {{checkNameRes.message||checkNameRes.data.wording||""}} @@ -114,7 +114,9 @@ export default { return { showPopup:true, userInputName: '',//用户输入的名称 - checkNameRes: "",//查询名称是否可用 + checkNameRes: { + data: {}, + },//查询名称是否可用 selectType:"",//选择的类型 localImg :{ diff --git a/src/subpackage/party/components/popup-content/miniapp-change-signature.vue b/src/subpackage/party/components/popup-content/miniapp-change-signature.vue new file mode 100644 index 0000000..a6a784e --- /dev/null +++ b/src/subpackage/party/components/popup-content/miniapp-change-signature.vue @@ -0,0 +1,434 @@ + + + + + \ No newline at end of file diff --git a/src/subpackage/party/pages/index/index.vue b/src/subpackage/party/pages/index/index.vue index 0e08383..b32ae7c 100644 --- a/src/subpackage/party/pages/index/index.vue +++ b/src/subpackage/party/pages/index/index.vue @@ -140,7 +140,7 @@ this.checkMiniAppRegist() }, computed: { - ...mapState(['brandInfo', ]), + // ...mapState(['brandInfo', ]), getManagerUrl(){ return this.url_manager[this.getUrlIndex()]; }, diff --git a/src/subpackage/party/pages/miniapp/regist.vue b/src/subpackage/party/pages/miniapp/regist.vue index 21e4be5..315517f 100644 --- a/src/subpackage/party/pages/miniapp/regist.vue +++ b/src/subpackage/party/pages/miniapp/regist.vue @@ -83,16 +83,17 @@ - --> + + - + --> @@ -200,17 +201,23 @@ --> - + > + + - + @sure="categoryChange" + @close="showChangeCategoryModule = false" + > @@ -221,7 +228,8 @@ import { servers } from '@/js/server'; import party_api from '../../../party/js/api'; import miniappChangeName from '../../components/popup-content/miniapp-change-name.vue'; -import miniappChangeJianJie from '../../components/popup-content/miniapp-change-jian-jie.vue'; +import miniappChangeSignature from '../../components/popup-content/miniapp-change-signature.vue'; +import miniappChangeCategory from '../../components/popup-content/miniapp-change-category.vue'; import { mapState @@ -229,20 +237,21 @@ import { export default { components: { - "miniapp-change-name": miniappChangeName, - "miniapp-change-jian-jie": miniappChangeJianJie, - + "app-change-name": miniappChangeName, + "app-change-signature": miniappChangeSignature, + "app-change-category": miniappChangeCategory, }, data() { return { + showChangeCategoryModule:false, showChangeNameModule:false, - showChangeJianJieModule:false, + showChangeSignatureModule:false, //showChangeSignatureModule showChangeJianJieModule brandInfo:"", appid: "",//小程序appid showPopup:false, directionClass:"", round:false, - animation:true, + animation:false, appInfo:{ "account_type": 3, "appid": "", @@ -324,6 +333,7 @@ export default { queryCategories_child: [],//二级子类目分类 queryCategories_index:[[0],[0]],//分类index二位数组 queryCategories_show:"请选择", + queryCategories_sport_index:null, @@ -404,7 +414,7 @@ export default { bindPickerChange_queryCategories(e) { console.log('picker发送选择改变,携带值为', e.target.value) let value = e.target.value; - this.queryIcpServiceContentTypes_index = value; + this.queryCategories_index = value; if (this.queryCategories[0].length != 0) { this.queryCategories_show = this.queryCategories[0][this.queryCategories_index[0]].name }; @@ -436,15 +446,21 @@ export default { // this.form.icp_applets.base_info.service_content_types = select_type }, bindPickerChange_queryCategories_column(e){ + console.log(e.detail) // 当滚动切换一级分类时,为当前的一级分类添加它的子类 if (e.detail.column == 0) { + let children_arr = this.queryCategories_child[e.detail.value] + if(this.queryCategories_sport_index>=0){ + this.queryCategories[1] = this.queryCategories_child[e.detail.value] + } + console.log("children_arr:",children_arr,e.detail.value) // #ifdef H5 // 在小程序中直接赋值无效 H5 可直接赋值 - this.queryCategories[1] = this.queryCategories_child[e.detail.value] + this.queryCategories[1] = children_arr // #endif // #ifdef MP-WEIXIN // 在 H5 环境下 $set 会导致一级分类无法滚动, 小程序正常运行 - this.$set(this.queryCategories, 1, this.queryCategories_child[e.detail.value]) + this.$set(this.queryCategories, 1, children_arr) // #endif } }, @@ -468,14 +484,12 @@ export default { console.log("clickSet",value) //value: 1(小程序名称) 2(小程序简介) 3(小程序类目) if(value == 1) this.showChangeNameModule = true; - if(value == 2) this.showChangeJianJieModule = true; - // this.showChangeNameModule = true; - // this.showChangeNameModule = true; + if(value == 2) this.showChangeSignatureModule = true; + if(value == 3) this.showChangeCategoryModule = true; }, async getAllCategoriesByType() { try { const res = await this.gatewayDo({ - // appid: row.mini_wechat_appid, appid: this.appid, module: '/cgi-bin/wxopen/getcategoriesbytype', method: 'POST', @@ -485,25 +499,21 @@ export default { }); console.log("getAllCategoriesByType:", res.data.errcode,res) if (res.data.errcode === 0) { - let allCategories = "" - let categories = res.data.categories_list.categories - // console.log("11111",res.data.categories_list.categories) + /* + getTwoArrFromWX(res,needSportFirst,needSportOnly) + 如: + res,true,true:只需要体育类目 + res,false,true:只需要体育类目 + res,true,false:将体育类目放在第一个 + res,false,false:使用默认数据,可选所有类目 + */ + let obj = this.getTwoArrFromWX(res,true,true)//只需要体育类目 - let obj = this.getTwoArrFromWX(res) console.log("obj:",obj) this.queryCategories = obj.array_obj; this.queryCategories_child = obj.child_arr; - /**/ - // console.log(res.data.categories_list.categories); - /** 属性 类型 说明 - id number 类目 ID - name bufffer 类目名称 - level number 类目层级 - father number 类目父级 ID - children array 子级类目 ID - sensitive_type number 是否为敏感类目(1 为敏感类目,需要提供相应资质审核;0 为非敏感类目,无需审核) - qualify - */ + this.queryCategories_sport_index = obj.index_sport; + } else { util.showNone(res.data.errmsg); } @@ -512,7 +522,12 @@ export default { } catch (error) { } }, - getTwoArrFromWX(res) { + getTwoArrFromWX(res,needSportFirst=false,needSportOnly = true) { + + if(needSportOnly){//只需要体育类目 + needSportFirst = true + } + let categories = res.data.categories_list.categories let firstLevel = [] @@ -550,14 +565,39 @@ export default { }) child_arr = firstLevel.map((item) => item.sub_list)// 将数据源中的二级分类 push 进 childArr,作为二级分类的数据源 + + let _index_sport=""; + if(needSportFirst){ //是否需要将体育类目放在第一个 + //将array_obj[0]中id=674的元素移动到第一个 + _index_sport = array_obj[0].findIndex((item)=>item.id==674) + console.log("_index_sport:",_index_sport) + + if(_index_sport>0){ + let _temp = array_obj[0][_index_sport] + array_obj[0].splice(_index_sport,1) + array_obj[0].unshift(_temp) + + let _temp_child = child_arr[_index_sport] + child_arr.splice(_index_sport,1) + child_arr.unshift(_temp_child) + } + } + + // if(!needSportFirst) array_obj[1].push(...child_arr[0]) //// 第一次打开时,默认给一级分类添加它的二级分类 + if(needSportOnly){//只需要体育类目 + array_obj[0].splice(1,array_obj[0].length-1) + } + return { firstLevel, //后台管理picker数据: [{一级name,type,children:[二级]},...] // array, //uni picker数据: [[一级name],[二级name]] // array_type,//uni picker type数据: [[一级type],[二级type]] array_obj,//uni picker obj数据: [[一级obj],[二级obj]] child_arr,//二级分类数据源 + index_sport:_index_sport,//需要移动的位置 + } // this.queryIcpServiceContentTypes = firstLevel; @@ -712,10 +752,14 @@ export default { nameChange(e){ console.log("nameChange",e) }, - jianjieChange(e){ + signatureChange(e){ console.log("jianjieChange",e) this.setJianJie(e) - this.showChangeJianJieModule = false + this.showChangeSignatureModule = false + }, + categoryChange(e){ + console.log("categoryChange",e) + this.showChangeCategoryModule = false }, async clickUploadImg(place,where,which){ let {localImg} = this