123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466 |
- <template>
- <view class="start-index">
- <view v-if="tabberPageLoadFlag[0]" :style="{display: currentIndex === 0 ? '' : 'none'}">
- <tn-nav-bar customBack>
- <view slot="back" class='tn-custom-nav-bar__back' @click="reFetchData()">
- <text v-if="!loading" class="tn-icon-circle-arrow" style="font-size: 50rpx;"></text>
- <view style="margin-top:6px" v-if="loading"><tn-loading :size="46"></tn-loading></view>
- </view>
-
- <view slot="default" style="display: flex;">
- <view style="flex:1;margin-left:25px;">
- <text>我要什么</text>
- </view>
- <view>
- <text class="tn-icon-add-fill" style="font-size: 30px;margin-right: 4px;"
- @click="addButton()"></text>
- </view>
- </view>
- </tn-nav-bar>
- <scroll-view class="custom-tabbar-page" scroll-y :refresher-enabled="isTop" @scroll="handleScroll" :refresher-triggered="triggered" @refresherpulling="onPulling" @refresherrestore="onRestore" @refresherrefresh="onRefresh" 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 :refresher-enabled="isTop" :refresher-triggered="triggered" @refresherrestore="onRestore" @refresherrefresh="onRefresh" 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>
- <canvas type="2d" id="myCanvas" style="width: 450px; height: 450px;left:9000px;position:fixed;"></canvas>
- </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 {
- isTop: true,
- triggered: false,
- _freshing: false,
-
- tabbarList: [{
- title: '我要什么',
- activeIcon: 'trust-fill',
- inactiveIcon: 'trust'
- },
- {
- title: '我有什么',
- activeIcon: 'team-fill',
- inactiveIcon: 'team'
- },
-
-
-
-
-
-
-
-
-
- {
- title: '供需发布平台',
- activeIcon: 'add-fill',
- inactiveIcon: 'add-circle',
-
- },
- {
- title: '我的',
- activeIcon: 'my-fill',
- inactiveIcon: 'my'
- }
- ],
-
- currentIndex: 0,
-
- tabberPageLoadFlag: [],
- shareData:{}
- }
- },
- onLoad(options) {
- const index = Number(options.index || 0)
-
- this.tabberPageLoadFlag = this.tabbarList.map((item, tabbar_index) => {
- return index === tabbar_index
- })
- this._freshing = false;
- 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()
- }
- },
- handleScroll(e){
- console.error('eee');
- console.error(e);
- console.error(e.detail.scrollTop);
- if(e.detail.scrollTop<1){
- console.error('11111111111111111');
-
- this.isTop = true;
- }else{
- this.isTop = false;
- }
- console.error(this.isTop,'11111111111111111');
-
- },
-
- 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()
- }
- },
- onPulling(e) {
- console.log("onpulling", e);
- },
- onRefresh(){
- if (this._freshing) return;
- this._freshing = true;
- if (this.currentIndex === 0) {
- console.error('this');
- this.$refs.home.reFetchData();
- }
- if (this.currentIndex === 1) {
- console.error('this');
- this.$refs.comm.reFetchData();
- }
- setTimeout(() => {
- console.error(11112222);
- this.triggered = false;
- this._freshing = false;
- this.isTop = false;
- }, 2000)
- },
- onRestore() {
- this.triggered = false;
- console.error("onRestore");
- },
-
- _switchTabbarPage(index) {
- const selectPageFlag = this.tabberPageLoadFlag[index]
- if (selectPageFlag === undefined) {
- return
- }
- if (selectPageFlag === false) {
- this.tabberPageLoadFlag[index] = true
- }
- this.currentIndex = index
- },
-
- getMyCanvasAndCtx(id) {
-
- return new Promise((resolve) => {
-
- const query = wx.createSelectorQuery();
-
- query
-
- .select(`#${id}`)
-
- .fields({
-
- node: true,
-
- size: true,
-
- })
-
- .exec((res) => {
-
- const canvas = res[0].node;
-
- const ctx = canvas.getContext("2d");
-
- const dpr = wx.getSystemInfoSync().pixelRatio;
-
- canvas.width = res[0].width * dpr;
-
- canvas.height = res[0].height * dpr;
-
- ctx.scale(dpr, dpr);
-
- const data = {
-
- canvas,
-
- ctx,
-
- };
-
- resolve(data);
-
- });
-
- });
-
- },
-
- sleep(time) {
- return new Promise((resolve) => setTimeout(resolve, time));
- },
- async initCanvas(){
-
- const { ctx, canvas } = await this.getMyCanvasAndCtx("myCanvas");
- ctx.save();
-
- ctx.font = "24px";
-
- ctx.fillText(this.shareData.company||this.shareData.contactPerson, 0, 32);
-
- ctx.fillText(this.shareData.content, 0, 72);
-
-
-
- await this.sleep(500);
-
- let url = null;
-
-
-
- const res = await wx.canvasToTempFilePath({ canvas });
-
- url = res.tempFilePath;
-
- return url;
-
- },
- onShareAppMessage: function(option) {
- if(option.from=="button"){
- if (this.currentIndex === 0) {
- this.$refs.home.hideSheet();
- }
- if (this.currentIndex === 1) {
- this.$refs.comm.hideSheet();
- }
-
- this.shareData=option.target.dataset.coupon;
-
- const promise = new Promise(async (resolve) => {
-
- const url = await this.initCanvas();
-
- resolve({
-
-
-
- path: `/pages/index/detail/detail?id=`+this.shareData.bisNo+'&isNeed='+(this.shareData.isNeed?1:0),
-
-
-
- });
-
- });
-
-
- return {
-
- path: `/pages/index/detail/detail?id=`+this.shareData.bisNo+'&isNeed='+(this.shareData.isNeed?1:0),
- promise,
- };
-
- }else{
- return {
-
- path: '/pages/index/index',
-
- };
- }
-
-
- },
-
- onShareAppMessage0: function(option) {
- if(option.from=="button"){
- if (this.currentIndex === 0) {
- this.$refs.home.hideSheet();
- }
- if (this.currentIndex === 1) {
- this.$refs.comm.hideSheet();
- }
- }
-
- return {
- title: '速立保',
- path: '/pages/index/index',
- };
- },
- }
- }
- </script>
- <style lang="scss" scoped>
- </style>
|