HuaJingwen 7 years ago
parent
commit
1f1c5f1681

+ 4 - 3
app.js

@@ -25,7 +25,7 @@ App({
25 25
     HOST: 'https://chaoshi.henhaojie.com'
26 26
   },
27 27
   login: function (func) {
28
-    let obj = {}, app = this, token = '';
28
+    let obj = {}, app = this, user = '';
29 29
     wx.login({
30 30
       success: function(res) {
31 31
         if (res.code) {
@@ -42,8 +42,9 @@ App({
42 42
                 },
43 43
                 success: function (resLogin) {
44 44
                   if (resLogin.data.errno == 0) {
45
-                    token = resLogin.data.rst.token;
46
-                    wx.setStorage({key:"token", data: token})
45
+                    user = resLogin.data.rst;
46
+                    // user_id = resLogin.data.rst.user_id;
47
+                    wx.setStorage({key:"user", data: user})
47 48
                     if (func) {
48 49
                       func();
49 50
                     }

+ 1 - 1
pages/application/application.js

@@ -10,7 +10,7 @@ Page({
10 10
     this.initApplication();
11 11
   },
12 12
   initApplication () {
13
-      var that = this, token = wx.getStorageSync('token'), list = [];
13
+      var that = this, token = wx.getStorageSync('user').token, list = [];
14 14
       if (that.data.page) {
15 15
         list = that.data.dataList
16 16
       }else{

+ 18 - 1
pages/card/card.js

@@ -12,11 +12,28 @@ Page({
12 12
     cardList: [],
13 13
     hasNext: true,
14 14
     page: 0,
15
-    hasPhone: true
15
+    hasPhone: false
16 16
   },
17 17
   onLoad: function () {
18 18
     this.initBanner();
19 19
     this.initCardList();
20
+    app.login();
21
+    // this.initConcact();
22
+  },
23
+  initConcact (event) {
24
+    var that = this, tel = wx.getStorageSync('tel') || '0', user_id = wx.getStorageSync('user').user_id || '0',
25
+          id = event.currentTarget.dataset.id;
26
+      // console.log(id);
27
+      // console.log(tel);
28
+    if (user_id != '0' || tel != '0') {
29
+      console.log('test');
30
+      that.setData({hasPhone: true})
31
+    }else{
32
+      that.setData({hasPhone: false});
33
+      wx.navigateTo({
34
+        url: "/pages/getPhone/getPhone?from=card&preid=" + id
35
+      })
36
+    }
20 37
   },
21 38
   initCardList: function () {
22 39
     var data = {}, list = [], that = this;

+ 1 - 3
pages/card/card.wxml

@@ -18,9 +18,7 @@
18 18
     <view class="split"></view>
19 19
     <view class="card-list">
20 20
         <view class="card-list-title">热门信用卡</view>
21
-      <block wx:for="{{cardList}}" wx:key="void">
22 21
          <!-- 使用热门推荐模板,传入当前循环对象item  -->
23
-        <template is="jiefItem2" data="{{...item}}"/>
24
-      </block>
22
+        <template is="jiefItem2" data="{{cardList, hasPhone}}"/>
25 23
     </view>
26 24
 </view>

+ 7 - 3
pages/getIt/getIt.js

@@ -5,15 +5,19 @@ Page({
5 5
    * 页面的初始数据
6 6
    */
7 7
   data: {
8
-    phone_number:'18888888888'
8
+    phone_number:'18888888888',
9
+    from: '',
10
+    preid: ''
9 11
   },
10 12
 
11 13
   /**
12 14
    * 生命周期函数--监听页面加载
13 15
    */
14 16
   onLoad: function (options) {
15
-    var that = this, tel = options.tel;
16
-    that.setData({phone_number: tel})
17
+    var that = this, tel = options.tel, preid = options.preid || 0, from = options.from;
18
+    console.log(tel);
19
+    console.log(preid);
20
+    that.setData({phone_number: tel, preid: preid, from: from})
17 21
   },
18 22
 
19 23
   /**

+ 10 - 5
pages/getIt/getIt.wxml

@@ -1,5 +1,10 @@
1
- <view class='pd64'> 
2
-  <image src='../resource/image/login_logo.png' class='logo_img'></image>
3
-  <view class='phone_number'>手机:<text>{{phone_number}}</text></view>
4
- </view> 
5
- <view class='details'>同时申请<text>3</text>款以上产品,成功率提升<text>90%</text></view> 
1
+
2
+<view class="getIt">
3
+    <view class='pd64'>
4
+        <image src='../resource/image/login_logo.png' class='logo_img'></image>
5
+        <view class='phone_number'>手机:<text>{{phone_number}}</text></view>
6
+    </view>
7
+    <view class='details'>同时申请<text>3</text>款以上产品,成功率提升<text>90%</text></view>
8
+    <button class="contact-btn" open-type="contact"  session-from="X_{{preid}}" wx-if="{{from == 'card' && preid != 0}}">立即申请</button>
9
+    <button class="contact-btn" open-type="contact"  session-from="Y_{{preid}}" wx-if="{{from != 'card' && preid != 0}}">立即申请</button>
10
+</view>

+ 19 - 5
pages/getIt/getIt.wxss

@@ -4,13 +4,10 @@ page {
4 4
   background: #f5f4f9;
5 5
 }
6 6
 
7
-view {
8
-  background: #fff;
9
-}
10
-
11 7
 .pd64 {
8
+    background: #fff;
12 9
     border-top: 1px solid#f5f4f9;
13
-  padding-bottom: 46px;
10
+    padding-bottom: 46px;
14 11
     text-align: center;
15 12
 }
16 13
 .phone_number{
@@ -37,6 +34,7 @@ view {
37 34
   display: block;
38 35
   height: 84px;
39 36
   width: 100%;
37
+  background: #fff;
40 38
   font-size: 14px;
41 39
   margin: auto;
42 40
   text-align: center;
@@ -48,3 +46,19 @@ view {
48 46
 .details  text {
49 47
   color: #db3232;
50 48
 }
49
+
50
+.getIt .contact-btn{
51
+    /*position: fixed;*/
52
+    /*left: 0;*/
53
+    /*bottom: 0;*/
54
+    width: 90%;
55
+    height: 40px;
56
+    line-height: 40px;
57
+    font-size: 15px;
58
+    background: #FFE100;
59
+    margin-top: 20px;
60
+}
61
+
62
+.getIt .contact-btn::after{
63
+    border: 0 none;
64
+}

+ 9 - 9
pages/getPhone/getPhone.js

@@ -2,12 +2,14 @@
2 2
 var app = getApp();
3 3
 Page({
4 4
   data: {
5
-    from: ''
5
+    from: '',
6
+    preid: ''
6 7
   },
7 8
   onLoad: function (options) {
8
-    console.log(options.from);
9
+    // console.log(options.from);
9 10
     var that = this;
10
-   that.setData({from: options.from});
11
+    that.setData({from: options.from, preid: options.preid});
12
+    // console.log(that.data.preid);
11 13
   },
12 14
   getPhoneNumber: function(e) {
13 15
     var that = this;
@@ -15,9 +17,7 @@ Page({
15 17
       console.log(e.detail.errMsg === 'getPhoneNumber:fail user deny');
16 18
       app.noticeModal('不绑定手机号的话就不能申请了哦');
17 19
     }else{
18
-      let token = wx.getStorageSync('token');
19
-      // console.log(e.detail.iv)
20
-      // console.log(e.detail.encryptedData)
20
+      let token = wx.getStorageSync('user').token;
21 21
       that.telHost(token, e.detail.iv, e.detail.encryptedData)
22 22
     }
23 23
   },
@@ -31,15 +31,15 @@ Page({
31 31
         var data = res.data
32 32
         // console.log(data);
33 33
         if (data.errno == '0'){
34
-          var tel = data.rst.phone_number
34
+          var tel = data.rst.phone_number;
35 35
           wx.setStorage({key:"tel", data: tel})
36 36
           if (that.data.from === 'mine') {
37 37
             wx.navigateTo({
38 38
               url: '/pages/application/application?tel=' + tel
39 39
             })
40
-          }else{
40
+          }else if(that.data.from === 'card' && that.data.preid){
41 41
             wx.navigateTo({
42
-              url: '/pages/getIt/getIt?tel=' + tel
42
+              url: '/pages/getIt/getIt?from='+that.data.from+'&preid='+ that.data.preid +'&tel=' + tel
43 43
             })
44 44
           }
45 45
 

+ 7 - 5
pages/mine/mine.js

@@ -10,17 +10,17 @@ Page({
10 10
     this.initInfo();
11 11
   },
12 12
   initInfo () {
13
-    var token = wx.getStorageSync('token'), data = {}, that = this;
13
+    var token = wx.getStorageSync('user').token, data = {}, that = this;
14 14
     console.log(token);
15 15
     if (token) {
16 16
       that.getInfo(token)
17 17
     }else{
18
-
19 18
       app.login(that.getInfo);
20 19
     }
21 20
   },
22 21
   getInfo (token) {
23
-    var that = this, token = token || wx.getStorageSync('token'), data = null;
22
+    var that = this, token = token || wx.getStorageSync('user').token, data = null;
23
+    console.log(token);
24 24
     wx.request({
25 25
       url: app.globalData.HOST + '/user/wx/personalCenter',
26 26
       method: 'POST',
@@ -35,8 +35,10 @@ Page({
35 35
     });
36 36
   },
37 37
   goApplication () {
38
-    var tel = wx.getStorageSync('tel');
39
-    if (tel) {
38
+    var tel = wx.getStorageSync('tel') || '0', user_id = wx.getStorageSync('user').user_id || '0';
39
+    console.log(user_id);
40
+    console.log(tel);
41
+    if (tel != '0' || user_id != '0') {
40 42
       wx.navigateTo({
41 43
         url: "/pages/application/application"
42 44
       })

+ 8 - 8
pages/template/template.wxml

@@ -17,22 +17,22 @@
17 17
 </template>
18 18
 
19 19
 <template name="jiefItem2">
20
-  <view class="weui-cells weui-cells_after-title template" bindtap="checkPhone">
21
-    <!-- <navigator url="/pages/details/details?id={{id}}" id="{{id}}"  hover-class="navigator-hover">  -->
20
+<block wx:for="{{cardList}}" wx:key="void">
21
+  <view class="weui-cells weui-cells_after-title template" data-id="{{item.id}}" bindtap="initConcact">
22 22
     <view class="weui-cell card-list-temp">
23 23
       <view class="weui-cell__hd">
24
-          <image class="icon" src="{{card_icon}}"/>
24
+          <image class="icon" src="{{item.card_icon}}"/>
25 25
       </view>
26 26
       <view class="weui-cell__bd">
27
-          <button class="contact-btn" open-type="contact" wx-if="{{hasPhone}}"/>
28
-          <view>{{name}}<view wx:for="{{keywords}}" wx:for-item="word" wx:key="void" wx-if="{{word == '礼'}}" class="weui-badge">{{word}}</view><view wx:for="{{keywords}}" wx:for-item="word" wx:key="void" wx-if="{{word !== '礼'}}" class="weui-badge other">{{word}}</view></view>
29
-          <view class="desc elli">{{desc}}</view>
30
-          <view class="desc elli" >申请人数<text class="emphasize">{{apply_num}}</text></view>
27
+          <button class="contact-btn" open-type="contact"  session-from="X_{{item.id}}" wx-if="{{hasPhone}}"/>
28
+          <view>{{item.name}}<view wx:for="{{item.keywords}}" wx:for-item="word" wx:key="void" wx-if="{{word == '礼'}}" class="weui-badge">{{word}}</view><view wx:for="{{item.keywords}}" wx:for-item="word" wx:key="void" wx-if="{{word !== '礼'}}" class="weui-badge other">{{word}}</view></view>
29
+          <view class="desc elli">{{item.desc}}</view>
30
+          <view class="desc elli" >申请人数<text class="emphasize">{{item.apply_num}}</text></view>
31 31
       </view>
32 32
     </view>
33 33
     <view class="weui-cell__ft weui-cell__ft_in-access"></view>
34
-    <!-- </navigator> -->
35 34
   </view>
35
+</block>
36 36
 </template>
37 37
 
38 38
 <template name="jiefItem3">

+ 2 - 2
project.config.json

@@ -1,7 +1,7 @@
1 1
 {
2 2
 	"description": "项目配置文件。",
3 3
 	"setting": {
4
-		"urlCheck": false,
4
+		"urlCheck": true,
5 5
 		"es6": true,
6 6
 		"postcss": true,
7 7
 		"minified": true,
@@ -24,7 +24,7 @@
24 24
 			"list": []
25 25
 		},
26 26
 		"miniprogram": {
27
-			"current": 4,
27
+			"current": 9,
28 28
 			"list": [
29 29
 				{
30 30
 					"id": -1,