123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245 |
- var app = getApp(); //获取应用实例
- const util = require('@/static/utils/util.js');
- const config = require('@/static/config.js');
- import requestConfig from '@/static/lib/requestConfig';
- import Bus from '@/common/bus';
- export default {
- data(){
- return {
- doubleClick:false,
- height: 0,
- selfTabbarBottom: '0px',
- computerHeight: 'calc(100vh - 58px)',
- statusBarHeight: 0,
- _scrollDistance: 0, //滑动的距离
- showShareOptions: false,
- showOption: true,
- }
- },
- watch:{
- },
- methods:{
- scrollExp(e) {
- if (e.detail) {
- this._scrollDistance = e.detail.scrollTop;
- if (this._scrollDistance >= 30) {
- this.showNav = true;
- if(this.hasOwnProperty('myNavBarData') && this.myNavBarData){
- this.myNavBarData.navBarColor = (this.globalCityListConfig && this.globalCityListConfig.backgroundColor) ? this.globalCityListConfig.backgroundColor: '#fff';
- if(!this.currentData){
- this.pageThemeColor = {
- textColor1:'#000'
- };
- }
- this.myNavBarData.titleColor = this.pageThemeColor.textColor1;
- this.myNavBarData.title = "城市列表";
- }
- } else {
- this.showNav = false;
- if(this.hasOwnProperty('myNavBarData') && this.myNavBarData){
- this.myNavBarData.navBarColor = 0;
- this.myNavBarData.titleColor = '#fff';
- this.myNavBarData.title = "";
- if(!this.currentData){
- this.pageThemeColor = {
- textColor1:'#fff'
- };
- }
- }
- }
- }
- },
- //顶部搜索按钮
- goToSearch(type=1) {
- // let url = '/subPackage/pages/searchCondition/searchCondition';
- let url = "/subPackage/pages/searchNewModule/searchNewModule";
- if(type==2){//新版的搜索页面
- url = "/subPackage/pages/searchNewModule/searchNewModule"
- }
- uni.navigateTo({
- url: url,
- success: () => {},
- });
- },
- //切换城市
- navigateToCity(e) {
- uni.navigateTo({
- url: '/subPackage/pages/addressModule/addressModule'
- });
- },
- //跳转到筛选页面
- // navigateToSearch(type) {
- // var _url = '/pages/screenSearchListModule/screenSearchListModule';
- // if (type) {
- // _url = _url + "?openType=" + type;
- // }
- // uni.navigateTo({
- // url: _url
- // });
- // },
- navigateFuc(e) {
- let eventOption = {};
- if (e) {
- // this.$emit("navigateFuc", e, eventOption);
- // 发送 navigateFucFromNav 主题 的Bus消息
- Bus.$emit('navigateFucFromNav', e);
- }
- },
- //颜色值转换
- hexToRgba(color, opacity) {
- return util.hexToRgba(color, opacity)
- },
- /**
- * 单页模式
- */
- showSingleModel() {
- app = getApp();
- let _scene = (app.globalData.launchInfo && app.globalData.launchInfo.scene) ? app.globalData.launchInfo
- .scene : '';
- if (_scene == '1154') { //单页模式下设置自定义导航栏无效
- this.specialHeight = (app.globalData.navigateStatusContainerHeight + 'px');
- this.specialTop = (app.globalData.navigateStatusContainerHeight + 'px');
- console.log("this.specialTop", this.specialTop);
- }
- this.singlePageStatus = app.globalData.singlePageStatus;
- },
- showShareOption() {
- this.showShareOptions = true;
- },
- hidenOption() {
- this.showOption = true;
- },
- getRandomArrayElements(arr, count) {
- var shuffled = arr.slice(0),
- i = arr.length,
- min = i - count,
- temp, index;
- while (i-- > min) {
- index = Math.floor((i + 1) * Math.random());
- temp = shuffled[index];
- shuffled[index] = shuffled[i];
- shuffled[i] = temp;
- }
- return shuffled.slice(min);
- },
- catchTouchMove: function() {
- return false;
- },
- //跳转到项目
- async navigateToProject(e) {
- var self = this;
- let houseId = e.currentTarget.dataset.houseid || e.currentTarget.dataset.houseid;
- let requestData = {
- houseId: houseId,
- requestCount: 1,
- componentCount: 1,
- };
- if(this.doubleClick){
- return false;
- }
- this.doubleClick = true;
- const res = await requestConfig('queryXcxPage', requestData, true);
- if (res && res.success && res.single && res.single.jsonString != null) {
- uni.navigateTo({
- url: '/pages/index/index?houseId=' + houseId,
- success: function() {},
- fail: function(res) {
- console.log(res)
- },
- complete() {
- self.doubleClick = false;
- }
- })
- } else {
- uni.showToast({
- title: '敬请期待',
- icon: 'none',
- duration: 1500,
- })
- this.doubleClick = false;
- }
- },
- async queryCityNews() {
- let res = await requestConfig('queryCityNews', {
- brandId: config.brandId,
- cityName: this.currentCity
- })
- if (res && res.success) {
- res.list.sort((a, b) => {
- return a.orderNumber - b.orderNumber
- })
- this.newsList = res.list.splice(0, 2)
- }
- },
- async goNews(e) {
- const data = e;
- var _link = "";
- var _title = "";
- if (data.type == 3) {
- _link = data.newsUrl;
- _title = data.title;
- } else if (data.type == 1 || !data.type) {
- _link = data.linkUrl;
- _title = data.title;
- } else {
- let res = await requestConfig('queryNewsById', {
- id: data.referNewsId
- })
- if (res.success && res.single) {
- if (res.single.type == 5) {
- _link = res.single.newsUrl;
- _title = res.single.title;
- } else {
- _link = res.single.linkUrl;
- _title = res.single.title;
- }
- }
- }
- let token = data.linkUrl.split('?newsToken=')[1] || '';
- app.checkNewsStatus(token, () => {
- if (data.content && data.content.length > 0) {
- let path = '/subPackage/pages/news/newsDetail/newsDetail?newsToken=' + token;
- console.log("path", path);
- uni.navigateTo({
- url: path,
- fail: function(res) {
- console.log(res)
- },
- })
- } else {
- if (app.checkWebviewLink(_link)) {
- uni.showToast({
- title: '敬请期待',
- icon: 'none',
- duration: 1500,
- })
- } else {
- uni.navigateTo({
- url: '/pages/webView/webView?view=' + encodeURIComponent(_link) +
- '&title=' + _title,
- fail: function(res) {
- console.log(res)
- },
- })
- }
- }
- }, () => {
- uni.showToast({
- title: '该页面已下线',
- icon: 'none',
- duration: 1500,
- })
- });
- },
- getDeviceInfor: function() {
- const res = uni.getSystemInfoSync();
- if (res.model.indexOf('iPhone') >= 0) {
- this.selfTabbarBottom = '0px';
- this.computerHeight = 'calc(100vh - 58px - 0px)';
- }
- this.height = app.globalData.navigateStatusContainerHeight;
- this.statusBarHeight = app.globalData.statusBarHeight;
- console.log("getDeviceInfor", res);
- },
- }
- }
|