zhuliu 1 vuosi sitten
vanhempi
commit
cf5bcd0261

+ 21 - 2
app.js

@@ -23,6 +23,26 @@ App({
     that.globalData.menuWidth = menuButtonInfo.width;
     wx.setStorageSync('height', that.globalData.navBarHeight)
     this.getPersonRights()
+
+    //静态图片地址
+    var Path = {
+      develop: {
+        localImagePath:'',
+        imghttp:'http://192.168.1.16:8801/fileManager/downloadFile?fileId='
+      }, // 开发环境地址  
+      trial: {
+        localImagePath:'.',
+        imghttp:'https://www.xsip.cn/fileManager/downloadFile?fileId='
+      }, // 测试环境地址  
+      release:{
+        localImagePath:'.',
+        imghttp:'https://www.xsip.cn/fileManager/downloadFile?fileId='
+      }, // 生产环境地址  
+    }
+    const accountInfo = wx.getAccountInfoSync();  
+    const envVersion = accountInfo.miniProgram.envVersion;  
+    that.globalData.localImagePath = Path[envVersion].localImagePath;
+    that.globalData.imghttp = Path[envVersion].imghttp;
   },
   globalData: {
     userInfo: null,
@@ -34,9 +54,8 @@ App({
     windowHeight:0,
     windowWidth:0,
     phone:'0755-82839168',
-    localImagePath:'.',//发布是'.',本地开发是''
+    localImagePath:'',//发布是'.',本地开发是''
     imghttp:'https://www.xsip.cn/fileManager/downloadFile?fileId='
-    // imghttp:'http://192.168.1.16:8801/fileManager/downloadFile?fileId='
   },
   getPersonRights(){
     api.getPersonRights({},false).then(res=>{

+ 15 - 3
app.json

@@ -21,7 +21,8 @@
     "pages/form/addProduct/addProduct",
     "pages/collectPatent/collectPatent",
     "pages/personalInformation/personalInformation",
-    "pages/patentDetails/patentDetails"
+    "pages/patentDetails/patentDetails",
+    "pages/showImageList/showImageList"
   ],
   "tabBar": {
     "list": [
@@ -65,9 +66,20 @@
     "wux-gallery": "/miniprogram_npm/wux-weapp/gallery/index",
     "wux-fab-button": "/miniprogram_npm/wux-weapp/fab-button/index",
     "van-icon": "/miniprogram_npm/@vant/weapp/icon/index",
-    "my-scroll-view":"/myComponents/scrollView/scrollView"
+    "my-scroll-view": "/myComponents/scrollView/scrollView"
   },
   "componentFramework": "glass-easel",
   "sitemapLocation": "sitemap.json",
-  "lazyCodeLoading": "requiredComponents"
+  "lazyCodeLoading": "requiredComponents",
+  "envConfig": {
+    "dev": {
+      "apiUrl": "https://dev-api.yourdomain.com"
+    },
+    "preview": {
+      "apiUrl": "https://preview-api.yourdomain.com"
+    },
+    "prod": {
+      "apiUrl": "https://prod-api.yourdomain.com"
+    }
+  }
 }

+ 1 - 1
miniprogram_npm/wux-weapp/gallery/index.wxml

@@ -2,7 +2,7 @@
     <swiper class="{{ classes.swiper }}" indicator-dots="{{ indicatorDots }}" indicator-color="{{ indicatorColor }}" indicator-active-color="{{ indicatorActiveColor }}" autoplay="{{ autoplay }}" interval="{{ interval }}" duration="{{ duration }}" circular="{{ circular }}" vertical="{{ vertical }}" current="{{ current }}" bindchange="onChange" wx:if="{{ in && images.length }}">
         <block wx:for="{{ images }}" wx:key="index">
             <swiper-item class="{{ classes.item }}">
-                <image class="{{ classes.img }}" mode="aspectFit" src="{{ item.image }}" data-index="{{ index }}" data-touch="{{ item.touch }}" bindtap="onTap" bindtouchstart="onTouchStart" bindtouchmove="onTouchMove" bindtouchend="onTouchEnd" style="transform: scale({{ item.touch.scale }}); transition: {{ transition || 'none' }}"></image>
+                <image class="{{ classes.img }}" mode="aspectFit" src="{{ item.image }}" data-index="{{ index }}" data-touch="{{ item.touch }}" bindtap="onTap" bindtouchstart="onTouchStart" bindtouchmove="onTouchMove" bindtouchend="onTouchEnd" style="transform: scale({{ item.touch.scale }}); transition: {{ transition || 'none' }}" 	show-menu-by-longpress></image>
                 <view class="{{ classes.remark }} {{ current === index ? prefixCls + '__remark--active' : '' }}" wx:if="{{ item.remark }}">{{ item.remark }}</view>
             </swiper-item>
         </block>

+ 11 - 13
pages/collectPatent/collectPatent.js

@@ -1,7 +1,7 @@
 // pages/collectPatent/collectPatent.js
 const app = getApp()
 const api = require('../../api/index')
-import {$wuxGallery} from '../../miniprogram_npm/wux-weapp/index'
+const showImage = require('../../utils/showImage')
 Page({
 
   /**
@@ -85,18 +85,16 @@ Page({
       imgs.push(this.data.imgHttp + imglist[i].guid)
     }
     current = this.data.imgHttp + current
-    $wuxGallery().show({
-      current,
-      urls: imgs.map((n) => ({ image: n, remark: n })),
-      indicatorDots: true,
-      indicatorColor: '#fff',
-      indicatorActiveColor: '#04BE02',
-      showDelete:false
-    })
-    // wx.previewImage({
-    //   current,
-    //   urls:imgs,
-    // })
+    showImage.showImageList(
+      {
+        current,
+        urls: imgs.map((n) => ({ image: n, remark: n })),
+        indicatorDots: true,
+        indicatorColor: '#fff',
+        indicatorActiveColor: '#04BE02',
+        showDelete:false
+      }
+    )
   },
   //获取收藏的专利
   selectCollectPatent(type){

+ 2 - 3
pages/collectPatent/collectPatent.wxml

@@ -1,7 +1,6 @@
 <!--pages/collectPatent/collectPatent.wxml-->
 <navBar></navBar>
 <van-notify id="van-notify" />
-<wux-gallery id="wux-gallery" />
 
 <view class="collectPatent">
   <view class="head">
@@ -24,8 +23,8 @@
               autoplay="{{false}}" interval="{{2000}}" duration="{{500}}">
               <block wx:if="{{item.imageList && item.imageList.length>0}}" wx:for="{{item.imageList}}" wx:for-item="img" wx:key="index">
                 <swiper-item>
-                  <view style="background-image: url('{{imgHttp+img.guid}}')" class="slide-image" data-current="{{img}}" data-imgList="{{item.imageList}}" bind:tap="previewImage"></view>  
-                  <!-- <image src="{{imgHttp+img.guid}}" class="slide-image" data-current="{{img}}" data-imgList="{{item.systemFileList}}" bindtap="previewImage" mode="aspectFit"/>   -->
+                  <!-- <view style="background-image: url('{{imgHttp+img.guid}}')" class="slide-image" data-current="{{img}}" data-imgList="{{item.imageList}}" bind:tap="previewImage"></view>   -->
+                  <image src="{{imgHttp+img.guid}}" data-current="{{img}}" data-imgList="{{item.imageList}}" bindtap="previewImage" class="slide-image" 	show-menu-by-longpress mode="aspectFit"/>  
                 </swiper-item>
               </block>
             </swiper>

+ 12 - 9
pages/patentDetails/patentDetails.js

@@ -1,7 +1,7 @@
 // pages/patentDetails/patentDetails.js
 const api = require('../../api/index')
 const app = getApp()
-import {$wuxGallery} from '../../miniprogram_npm/wux-weapp/index'
+const showImage = require('../../utils/showImage')
 Page({
 
   /**
@@ -55,14 +55,17 @@ Page({
       imgs.push(this.data.imgHttp + imglist[i].guid)
     }
     current = this.data.imgHttp + current
-    $wuxGallery().show({
-      current,
-      urls: imgs.map((n) => ({ image: n, remark: n })),
-      indicatorDots: true,
-      indicatorColor: '#fff',
-      indicatorActiveColor: '#04BE02',
-      showDelete:false
-    })
+    showImage.showImageList(
+      {
+        current,
+        urls: imgs.map((n) => ({ image: n, remark: n })),
+        indicatorDots: true,
+        indicatorColor: '#fff',
+        indicatorActiveColor: '#04BE02',
+        showDelete:false
+      }
+    )
+ 
   },
   //获取专利详情
   selectPatentInfoByPatentNo(){

+ 2 - 2
pages/patentDetails/patentDetails.wxml

@@ -1,6 +1,5 @@
 <!--pages/patentDetails/patentDetails.wxml-->
 <navBar></navBar>
-<wux-gallery id="wux-gallery" />
 <van-notify id="van-notify" />
 <view class="patentDetail">
   <view class="patentNo">
@@ -80,7 +79,8 @@
     <swiper indicator-dots="{{true}}"  autoplay="{{false}}" interval="{{2000}}" duration="{{500}}">
       <block wx:if="{{patent.imageList && patent.imageList.length>0}}" wx:for="{{patent.imageList}}" wx:for-item="img" wx:key="index">
         <swiper-item>
-          <view style="background-image: url('{{imgHttp+img.guid}}')" class="slide-image" data-current="{{patent}}" data-imgList="{{patent.imageList}}" bind:tap="previewImage"></view>  
+          <!-- <view style="background-image: url('{{imgHttp+img.guid}}')" class="slide-image" data-current="{{patent}}" data-imgList="{{patent.imageList}}" bind:tap="previewImage"></view>   -->
+          <image src="{{imgHttp+img.guid}}" data-current="{{img}}" data-imgList="{{patent.imageList}}" bindtap="previewImage" class="slide-image" 	show-menu-by-longpress mode="aspectFit"/>  
         </swiper-item>
       </block>
     </swiper>

+ 12 - 13
pages/searchResults/searchResults.js

@@ -1,7 +1,7 @@
 // pages/searchResults/searchResults.js
 const app = getApp()
 const api = require('../../api/index')
-import { $wuxGallery} from '../../miniprogram_npm/wux-weapp/index'
+const showImage = require('../../utils/showImage')
 Page({
 
   /**
@@ -122,18 +122,17 @@ Page({
       imgs.push(this.data.imgHttp + imglist[i].guid)
     }
     current = this.data.imgHttp + current
-    $wuxGallery().show({
-      current,
-      urls: imgs.map((n) => ({ image: n, remark: n })),
-      indicatorDots: true,
-      indicatorColor: '#fff',
-      indicatorActiveColor: '#04BE02',
-      showDelete:false
-    })
-    // wx.previewImage({
-    //   current,
-    //   urls:imgs,
-    // })
+    showImage.showImageList(
+      {
+        current,
+        urls: imgs.map((n) => ({ image: n, remark: n })),
+        indicatorDots: true,
+        indicatorColor: '#fff',
+        indicatorActiveColor: '#04BE02',
+        showDelete:false
+      }
+    )
+
   },
   //修改输入的关键词
   changeKeyword(e){

+ 3 - 4
pages/searchResults/searchResults.wxml

@@ -1,6 +1,5 @@
 <!--pages/searchResults/searchResults.wxml-->
 <navBar></navBar>
-<wux-gallery id="wux-gallery" />
 <van-notify id="van-notify" />
 <myFloatButton count="{{patentNoList.length}}" bind:click="clickButton"></myFloatButton>
 <myDialog isShown="{{showDialog}}" title="选择关注的类型" bindcancel="closeDialog" bindconfirm="confirm">
@@ -115,9 +114,9 @@
             <swiper indicator-dots="{{true}}"
             autoplay="{{false}}" interval="{{2000}}" duration="{{500}}">
             <block wx:if="{{item.imageList && item.imageList.length>0}}" wx:for="{{item.imageList}}" wx:for-item="img" wx:key="index">
-              <swiper-item>
-                <view style="background-image: url('{{imgHttp+img.guid}}')" class="slide-image" data-current="{{img}}" data-imgList="{{item.imageList}}" bind:tap="previewImage"></view>  
-                 <!-- <image src="{{imgHttp+img.guid}}" class="slide-image" data-current="{{img}}" data-imgList="{{item.systemFileList}}" bindtap="previewImage" mode="aspectFit"/>   -->
+              <swiper-item >
+                <!-- <view style="background-image: url('{{imgHttp+img.guid}}')" class="slide-image" data-current="{{img}}" data-imgList="{{item.imageList}}" bind:tap="previewImage"></view>   -->
+                 <image src="{{imgHttp+img.guid}}" data-current="{{img}}" data-imgList="{{item.imageList}}" bindtap="previewImage" class="slide-image" 	show-menu-by-longpress mode="aspectFit"/>  
               </swiper-item>
             </block>
           </swiper>

+ 12 - 12
pages/selectedPatents/selectedPatents.js

@@ -2,6 +2,7 @@
 import { $wuxGallery} from '../../miniprogram_npm/wux-weapp/index'
 const app = getApp()
 const api = require('../../api/index')
+const showImage = require('../../utils/showImage')
 Page({
 
   /**
@@ -63,18 +64,17 @@ Page({
       imgs.push(this.data.imgHttp + imglist[i].guid)
     }
     current = this.data.imgHttp + current
-    $wuxGallery().show({
-      current,
-      urls: imgs.map((n) => ({ image: n, remark: n })),
-      indicatorDots: true,
-      indicatorColor: '#fff',
-      indicatorActiveColor: '#04BE02',
-      showDelete:false
-    })
-    // wx.previewImage({
-    //   current,
-    //   urls:imgs,
-    // })
+    showImage.showImageList(
+      {
+        current,
+        urls: imgs.map((n) => ({ image: n, remark: n })),
+        indicatorDots: true,
+        indicatorColor: '#fff',
+        indicatorActiveColor: '#04BE02',
+        showDelete:false
+      }
+    )
+
   },
   //人工服务
   humanServices(){

+ 2 - 3
pages/selectedPatents/selectedPatents.wxml

@@ -1,7 +1,6 @@
 <!--pages/selectedPatents/selectedPatents.wxml-->
 <navBar></navBar>
 <van-notify id="van-notify" />
-<wux-gallery id="wux-gallery" />
 <view class="selectedPatents">
   <view class="head">
     <view>
@@ -26,8 +25,8 @@
             autoplay="{{false}}" interval="{{2000}}" duration="{{500}}">
             <block wx:if="{{item.imageList && item.imageList.length>0}}" wx:for="{{item.imageList}}" wx:for-item="img" wx:key="index">
               <swiper-item>
-                <view style="background-image: url('{{imgHttp+img.guid}}')" class="slide-image" data-current="{{img}}" data-imgList="{{item.imageList}}" bind:tap="previewImage"></view>  
-                 <!-- <image src="{{imgHttp+img.guid}}" class="slide-image" data-current="{{img}}" data-imgList="{{item.systemFileList}}" bindtap="previewImage" mode="aspectFit"/>   -->
+                <!-- <view style="background-image: url('{{imgHttp+img.guid}}')" class="slide-image" data-current="{{img}}" data-imgList="{{item.imageList}}" bind:tap="previewImage"></view>   -->
+                <image src="{{imgHttp+img.guid}}" data-current="{{img}}" data-imgList="{{item.imageList}}" bindtap="previewImage" class="slide-image" 	show-menu-by-longpress mode="aspectFit"/>  
               </swiper-item>
             </block>
           </swiper>

+ 89 - 0
pages/showImageList/showImageList.js

@@ -0,0 +1,89 @@
+// pages/showImageList/showImageList.js
+import { $wuxGallery} from '../../miniprogram_npm/wux-weapp/index'
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+    config:{}
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad(options) {
+    const eventChannel = this.getOpenerEventChannel()
+    var that = this
+    // eventChannel.emit('acceptDataFromOpenedPage', {data: 'test'});
+    // eventChannel.emit('someEvent', {data: 'test'});
+    // 监听acceptDataFromOpenerPage事件,获取上一页面通过eventChannel传送到当前页面的数据
+    eventChannel.on('acceptDataFromOpenerPage', function(data) {
+      that.setData(
+        {
+          config:data.data
+        }
+      )
+      that.previewImage()
+    })
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow() {
+
+  },
+
+  previewImage(){
+    $wuxGallery().show(
+      {
+        ...this.data.config,
+        onTap(current, urls) {
+          return false
+        },
+      })
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload() {
+
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh() {
+
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom() {
+
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage() {
+
+  }
+})

+ 6 - 0
pages/showImageList/showImageList.json

@@ -0,0 +1,6 @@
+{
+  "navigationStyle": "custom",
+  "usingComponents": {
+    "wux-gallery": "/miniprogram_npm/wux-weapp/gallery/index"
+  }
+}

+ 3 - 0
pages/showImageList/showImageList.wxml

@@ -0,0 +1,3 @@
+<!--pages/showImageList/showImageList.wxml-->
+<navBar></navBar>
+<wux-gallery id="wux-gallery" />

+ 1 - 0
pages/showImageList/showImageList.wxss

@@ -0,0 +1 @@
+/* pages/showImageList/showImageList.wxss */

+ 9 - 1
utils/request.js

@@ -1,6 +1,7 @@
 // request.js  
 import Notify from '../miniprogram_npm/@vant/weapp/notify/notify';
 import {  $stopWuxRefresher} from '../miniprogram_npm/wux-weapp/index';
+
 // 配置项  
 const config = {  
   // baseURL: 'http://192.168.1.18:8901', // 基础URL  
@@ -13,7 +14,14 @@ const config = {
   // 其他全局配置...  
   tabbar:["pages/index/index","pages/hotProduct/hotProduct","pages/mine/mine"]
 };  
-
+const apiUrl = {  
+  develop: 'https://www.xsip.cn', // 开发环境地址  
+  trial: 'https://www.xsip.cn/test', // 测试环境地址  
+  release: 'https://www.xsip.cn' // 生产环境地址  
+};
+const accountInfo = wx.getAccountInfoSync();  
+const envVersion = accountInfo.miniProgram.envVersion;  
+config.baseURL = apiUrl[envVersion];
 function getPages(){
   var obj = {
     type: 'danger'

+ 21 - 0
utils/showImage.js

@@ -0,0 +1,21 @@
+function showImageList(obj){
+  wx.navigateTo({
+    url: '/pages/showImageList/showImageList',
+    events: {
+      // 为指定事件添加一个监听器,获取被打开页面传送到当前页面的数据
+      acceptDataFromOpenedPage: function(data) {
+        console.log(data)
+      },
+      someEvent: function(data) {
+        console.log(data)
+      }
+    },
+    success: function(res) {
+      // 通过eventChannel向被打开页面传送数据
+      res.eventChannel.emit('acceptDataFromOpenerPage', { data: obj })
+    }
+  })
+}
+module.exports = {  
+  showImageList: (data) => showImageList(data)
+};

+ 8 - 4
utils/upload.js

@@ -1,6 +1,5 @@
 // 配置项  
 import Notify from '../miniprogram_npm/@vant/weapp/notify/notify';
-import { $startWuxRefresher, $stopWuxRefresher,$stopWuxLoader} from '../miniprogram_npm/wux-weapp/index';
 const token = wx.getStorageSync('token')
 const config = {  
   // baseURL: 'http://192.168.1.6:8802', // 基础URL 
@@ -14,6 +13,14 @@ const config = {
   // 其他全局配置...  
   tabbar:["pages/index/index","pages/hotProduct/hotProduct","pages/mine/mine"] 
 };  
+const apiUrl = {  
+  develop: 'http://192.168.1.18:8802', // 开发环境地址  
+  trial: 'https://www.xsip.cn', // 测试环境地址  
+  release: 'https://www.xsip.cn' // 生产环境地址  
+};
+const accountInfo = wx.getAccountInfoSync();  
+const envVersion = accountInfo.miniProgram.envVersion;  
+config.baseURL = apiUrl[envVersion];
 function getPages(){
   var obj = {
     type: 'danger'
@@ -82,9 +89,6 @@ function upload(url="/fileManager/uploadNormalFile", path = '', header = {},form
           
           reject(res.data.message || '未知错误');  
         }  
-        if($stopWuxRefresher()){
-          $stopWuxRefresher()
-        }
       },  
       fail: function(error) { 
         console.log(error)