123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266 |
- <template>
- <view class="start-index">
- <view v-if="tabberPageLoadFlag[0]" :style="{display: currentIndex === 0 ? '' : 'none'}">
- <scroll-view class="custom-tabbar-page" scroll-y enable-back-to-top @scrolltolower="tabbarPageScrollLower">
- <Home ref="home"></Home>
- </scroll-view>
- </view>
- <view v-if="tabberPageLoadFlag[1]" :style="{display: currentIndex === 1 ? '' : 'none'}">
- <scroll-view class="custom-tabbar-page" scroll-y enable-back-to-top @scrolltolower="tabbarPageScrollLower">
- <Comm ref="comm"></Comm>
- </scroll-view>
- </view>
- <view v-if="tabberPageLoadFlag[2]" :style="{display: currentIndex === 2 ? '' : 'none'}">
- <scroll-view class="custom-tabbar-page" scroll-y enable-back-to-top @scrolltolower="tabbarPageScrollLower">
- <Discovery ref="discovery"></Discovery>
- </scroll-view>
- </view>
-
- <view v-if="tabberPageLoadFlag[3]" :style="{display: currentIndex === 3 ? '' : 'none'}">
- <scroll-view class="custom-tabbar-page" scroll-y enable-back-to-top @scrolltolower="tabbarPageScrollLower">
- <Mine ref="mine"></Mine>
- </scroll-view>
- </view>
- <tn-tabbar v-model="currentIndex" :list="tabbarList" activeColor="#1d60b1" inactiveColor="#AAAAAA"
- activeIconColor="#1d60b1" :animation="true" :safeAreaInsetBottom="true" @change="switchTabbar"></tn-tabbar>
- </view>
- </template>
- <script>
- import Home from '../home/home.vue'
- import Comm from '../comm/comm.vue'
- import Discovery from '../discovery/discovery.vue'
- import Mine from '../mine/mine.vue'
- import request from '../../utils/request'
- export default {
- components: {
- Home,
- Comm,
- Discovery,
- Mine
- },
- data() {
- return {
-
- tabbarList: [{
- title: '我要什么',
- activeIcon: 'home-smile-fill',
- inactiveIcon: 'home-smile'
- },
- {
- title: '我有什么',
- activeIcon: 'shop-fill',
- inactiveIcon: 'shop'
- },
-
-
-
-
-
-
-
-
-
- {
- title: '供需发布平台',
- activeIcon: 'add-fill',
- inactiveIcon: 'add-circle',
-
- },
- {
- title: '我的',
- activeIcon: 'my-fill',
- inactiveIcon: 'my'
- }
- ],
-
- currentIndex: 0,
-
- tabberPageLoadFlag: []
- }
- },
- onLoad(options) {
- const index = Number(options.index || 0)
-
- this.tabberPageLoadFlag = this.tabbarList.map((item, tabbar_index) => {
- return index === tabbar_index
- })
- this.switchTabbar(index);
- let that = this;
-
-
-
-
-
-
-
-
-
-
-
- },
- onShow(){
- if (this.currentIndex === 3&&this.$refs.mine) {
- this.$refs.mine.getContentRectInfo();
- }
- if (this.currentIndex === 1&&this.$refs.comm) {
- this.$refs.comm.fetchData();
- }
- },
- methods: {
-
- switchTabbar(index) {
- this._switchTabbarPage(index)
- if (index !== 1) {
- this.$refs?.commRef?.stopAllVideo()
- }
- },
-
- getOpenId(code) {
- const that = this;
- request.post('/wxma/code2Session',{
- code: code,
- platType: "slb",
- mpType: "engineer",
- }).then(res=>{
- console.error(res);
- if(res.success){
-
- uni.setStorageSync('userMap', JSON.stringify(res.resultMap));
- }
-
- })
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- },
- loginByCode(frontId) {
- const that = this;
- uni.setStorageSync('loginStatus', 'false');
- wx.getUserInfo({
- success: function(res) {
- console.error(res);
- request.post("/slbMpAutoLogin", {
- code:frontId,
- appType:'ma',
- encryptedData:res.encryptedData,
- iv: res.iv
- }, {
- login: false,
- warn:false,
- loading:false
- }).then(res2=>{
- console.error(res2);
- if(res2.success){
-
- uni.setStorageSync('loginStatus', 'true');
- uni.setStorageSync('userMap', JSON.stringify(res2.resultMap));
- uni.setStorageSync('userNo', res2.resultMap.accountName);
- }else{
- console.error(12345);
- uni.setStorageSync('loginStatus', 'false');
-
-
- uni.login({
- success(res) {
- console.error(res);
- that.getOpenId(res.code);
- },
- fail(res) {
- console.error(res);
- uni.hideLoading();
- }
- });
-
- }
- console.error(res2);
- });
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- }
- })
-
-
- },
-
- tabbarPageScrollLower(e) {
- if (this.currentIndex === 0) {
- this.$refs.home.loadMore();
- }
- if (this.currentIndex === 1) {
- this.$refs.comm.loadMore();
- }
- if (this.currentIndex === 2) {
- this.$refs.discovery.getRandomData && this.$refs.discovery.getRandomData()
- }
- },
-
- _switchTabbarPage(index) {
- const selectPageFlag = this.tabberPageLoadFlag[index]
- if (selectPageFlag === undefined) {
- return
- }
- if (selectPageFlag === false) {
- this.tabberPageLoadFlag[index] = true
- }
- this.currentIndex = index
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- </style>
|