k.zhang 4 years ago
parent
commit
55a9c418e3
4 changed files with 80 additions and 35 deletions
  1. 18 1
      app.js
  2. 48 23
      pages/details/details.js
  3. 12 9
      pages/shouye/shouye.js
  4. 2 2
      project.config.json

+ 18 - 1
app.js

@@ -10,10 +10,27 @@ App({
     wx.login({
       success: res => {
         // 发送 res.code 到后台换取 openId, sessionKey, unionId
+        console.log(res)
+        wx.request( { 
+          url: this.globalData.url + "/v1/user/open.id/set", 
+          header: { 
+           "Content-Type": "application/json"
+          }, 
+          method: "POST",
+          data:  { code: res.code }, 
+          complete: function( res ) { 
+           if (res.data.code == 200){
+            wx.setStorageSync('openId', res.data.data.openid)
+           }
+          
+          } 
+         }) 
       }
     })
   },
   globalData: {
-    userInfo: null
+    userInfo: null,
+    //url:"http://127.0.0.1:8081"
+    url:"http://www.tao1024.com:8081"
   }
 })

+ 48 - 23
pages/details/details.js

@@ -1,4 +1,6 @@
 // pages/details/details.js
+const app = getApp()
+const link = app.globalData.url
 Page({
 
   /**
@@ -17,35 +19,58 @@ Page({
     var that=this
     const goodsSign=options.goodsSign
     const searchId=options.searchId
-    const pid = "9112489_209622235"
-
-    that.p_id = pid
-    that.goods_sign = goodsSign
-    that.search_id = searchId
+    //const pid = "9112489_209622235"
+    var pid = "9112489_212035116"
+    var opneId = wx.getStorageSync('openId')
+    console.log(opneId)
+    //获取pid
     wx.request({
-    url: 'https://www.shisanmiao.com/v1/pdd/ddk/detail', 
-    data: { goods_sign: goodsSign, search_id: searchId,pid: pid }, 
-    header: { 
-      "Content-Type": "application/json"
-     }, 
-     method: "POST",
+      url: link + '/v1/user/pid/get', 
+      data: { openId: opneId }, 
+      header: { 
+        "Content-Type": "application/json"
+       }, 
+       method: "POST",
+     
+      success (res) {
+        console.log(res)
+        console.log(pid)
+        if (res.data.code == 200){
+          pid = res.data.data.pid
+        }
+        console.log(pid)
+        that.p_id = pid
+        that.goods_sign = goodsSign
+        that.search_id = searchId
+        wx.request({
+        url: link + '/v1/pdd/ddk/detail', 
+        data: { goods_sign: goodsSign, search_id: searchId,pid: pid }, 
+        header: { 
+          "Content-Type": "application/json"
+         }, 
+         method: "POST",
+       
+        success (res) {
+          console.log(res)
+          that.setData({
+          goodsDetails: res.data.data.goods_detail_response.goods_details,
+          searchId:searchId
+         })
+        
+        }
+      })
+      }
+    })
+
+
    
-    success (res) {
-      console.log(res)
-      that.setData({
-      goodsDetails: res.data.data.goods_detail_response.goods_details,
-      searchId:searchId
-     })
-    
-    }
-  })
   },
   counponBtn:function(e){
     var that = this
   console.log("pdd")
-  
+  console.log(that.p_id)
   wx.request({
-    url: 'https://www.shisanmiao.com/v1/pdd/url/generate', 
+    url: link + '/v1/pdd/url/generate', 
     data: { goods_sign_list: [that.goods_sign], search_id: that.search_id,p_id: that.p_id,generate_we_app:"true" }, 
     header: { 
       "Content-Type": "application/json"
@@ -64,7 +89,7 @@ Page({
     wx.navigateToMiniProgram({
     appId: 'wx32540bd863b27570',
     path: path,
-        success(res) {
+        success(res) { 
     }
     })
     }

+ 12 - 9
pages/shouye/shouye.js

@@ -1,5 +1,7 @@
 // pages/shouye/shouye.js
 const util = require('../../utils/util.js')
+const app = getApp()
+const link = app.globalData.url
 Page({
 
   /**
@@ -72,7 +74,8 @@ Page({
   show:true,
   lType:"loading",
   activity_tags:"",
-  pid:"9112489_209622235",
+  // pid:"9112489_209622235",
+  pid:"9112489_212035116",
   keyword:""
   },
 
@@ -116,7 +119,7 @@ Page({
     that.pageSize = 18
         
     wx.request( { 
-      url: "https://www.shisanmiao.com/v1/set", 
+      url: link + "/v1/set", 
       header: { 
        "Content-Type": "application/json"
       }, 
@@ -140,7 +143,7 @@ Page({
         //获取数据
       setTimeout(that._asyncData, 0);
       wx.request( { 
-       url: "https://www.shisanmiao.com/v1/pdd/ddk/search", 
+       url: link + "/v1/pdd/ddk/search", 
        header: { 
         "Content-Type": "application/json"
        }, 
@@ -182,14 +185,14 @@ Page({
     console.log(e)
     that.keyword = e.detail.value
     that.activity_tags = ""
-    that.pid = "9112489_209622235"
+    that.pid = "9112489_212035116"
     console.log(that.keyword)
     console.log(that.pid)
 
     that.page = 1
     that.pageSize = 18
      wx.request( { 
-     url: "https://www.shisanmiao.com/v1/pdd/ddk/search", 
+     url: link + "/v1/pdd/ddk/search", 
      header: { 
        "Content-Type": "application/json"
      }, 
@@ -238,7 +241,7 @@ Page({
    that.page = 1
    that.pageSize = 18
     wx.request( { 
-    url: "https://www.shisanmiao.com/v1/pdd/ddk/search", 
+    url: link + "/v1/pdd/ddk/search", 
     header: { 
       "Content-Type": "application/json"
     }, 
@@ -272,7 +275,7 @@ Page({
     var that=this
     var currentPage=that.data.page+1;
     wx.request({
-      url: 'https://www.shisanmiao.com/v1/pdd/ddk/search', 
+      url: link + '/v1/pdd/ddk/search', 
       data: {
         listId:that.data.listId,
         pageSize:10,
@@ -329,7 +332,7 @@ Page({
                 that.activity_tags = ""
 
                  wx.request( { 
-                 url: "https://www.shisanmiao.com/v1/pdd/ddk/search", 
+                 url: link + "/v1/pdd/ddk/search", 
                  header: { 
                    "Content-Type": "application/json"
                  }, 
@@ -401,7 +404,7 @@ Page({
    
    that.page +=1
   wx.request( { 
-   url: "https://www.shisanmiao.com/v1/pdd/ddk/search", 
+   url: link + "/v1/pdd/ddk/search", 
   //  url: "http://127.0.0.1:8081/v1/pdd/ddk/search", 
    header: { 
     "Content-Type": "application/json"

+ 2 - 2
project.config.json

@@ -4,7 +4,7 @@
     "ignore": []
   },
   "setting": {
-    "urlCheck": true,
+    "urlCheck": false,
     "es6": true,
     "enhance": true,
     "postcss": true,
@@ -23,7 +23,7 @@
     "compileHotReLoad": false,
     "useMultiFrameRuntime": true,
     "useApiHook": true,
-    "useApiHostProcess": false,
+    "useApiHostProcess": true,
     "babelSetting": {
       "ignore": [],
       "disablePlugins": [],