From 2988e57b024198058192e20f4c213de24a4f9f01 Mon Sep 17 00:00:00 2001
From: shenzm <zhimin.shen@yoho.cn>
Date: Thu, 4 Aug 2016 10:33:01 +0800
Subject: [PATCH] fix bug

---
 apps/me/models/index.js                               |   2 +-
 public/js/common/intercept-click.js                   |  10 +++++++---
 public/js/index.js                                    |   2 +-
 public/vue/component/product/filter.vue.bk            | 194 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 public/vue/component/product/filter/filter-sub.vue.bk |  85 -------------------------------------------------------------------------------------
 public/vue/me/exchange.vue                            |  16 ++++++++--------
 public/vue/me/fav-brand-list.vue                      |  34 +++++++++-------------------------
 public/vue/me/fav-product-list.vue                    |  33 +++++++++------------------------
 public/vue/me/order-detail.vue                        |   4 ++--
 public/vue/me/refund.vue                              |  17 ++++++++---------
 public/vue/me/refund/status.vue                       |  21 ++-------------------
 11 files changed, 47 insertions(+), 371 deletions(-)
 delete mode 100644 public/vue/component/product/filter.vue.bk
 delete mode 100644 public/vue/component/product/filter/filter-sub.vue.bk

diff --git a/apps/me/models/index.js b/apps/me/models/index.js
index 0790544..73bc171 100644
--- a/apps/me/models/index.js
+++ b/apps/me/models/index.js
@@ -21,7 +21,7 @@ const _getUserProfileData = exports.getUserProfileData = (uid) => {
     }, {
         code: 200
     }).then(result => {
-        return result.data;
+        return result.data || {};
     });
 };
 
diff --git a/public/js/common/intercept-click.js b/public/js/common/intercept-click.js
index 75a2547..c72ae77 100644
--- a/public/js/common/intercept-click.js
+++ b/public/js/common/intercept-click.js
@@ -215,8 +215,7 @@ const matchHeader = (url) => {
     return header;
 };
 
-
-module.exports = (url) => {
+const intercept = (url) => {
     if (yoho.isApp) {
         let [path, qs] = url.split('?');
 
@@ -272,4 +271,9 @@ module.exports = (url) => {
     } else {
         location.href = url;
     }
-};
+}
+
+module.exports = {
+    titleMap: titleMap,
+    intercept: intercept
+}
diff --git a/public/js/index.js b/public/js/index.js
index 0fb4f50..7905826 100644
--- a/public/js/index.js
+++ b/public/js/index.js
@@ -37,7 +37,7 @@ $(() => {
     $body.on('click', 'a[href]', function() {
         // 拦截跳转
         if (!$(this).hasClass('no-intercept')) {
-            interceptClick($(this).attr('href'));
+            interceptClick.intercept($(this).attr('href'));
             return false;
         }
     });
diff --git a/public/vue/component/product/filter.vue.bk b/public/vue/component/product/filter.vue.bk
deleted file mode 100644
index 7706481..0000000
--- a/public/vue/component/product/filter.vue.bk
+++ /dev/null
@@ -1,194 +0,0 @@
-<template>
-    <div class="filter" :class="{ 'filter-open': isVisible}">
-        <div class="filter-actions">
-            <a href="javascript:;" class="filter-action" @click="clearVals">清空</a>
-            <button class="button button-small filter-action" @click="okAction">确定</button>
-        </div>
-        <div class="filter-params">
-            <ul class="filter-cates">
-                <li class="filter-cate" v-for="classify in config" @click="entrySub($key)">
-                    <i class="icon icon-right right"></i>
-                    <span class="filter-cate-label">{{$key | txt }}</span>
-                    <span class="filter-cate-val">{{params[$key] | unifyTxt $key }}</span>
-                </li>
-            </ul>
-        </div>
-    </div>
-</template>
-<script>
-    const $ = require('jquery');
-    const bus = require('common/vue-bus');
-    const Overlay = require('common/overlay');
-    const yoho = require('yoho');
-
-    module.exports = {
-        props: {
-            config: Object,
-            isVisible: Boolean,
-            action: '',
-        },
-        data: function() {
-            return {
-                // 选择的值
-                params: {},
-
-                // 确定的值
-                selected: {}
-            };
-        },
-        watch: {
-            isVisible(newVal) {
-                if (newVal) {
-                    this.overlay.show();
-                } else {
-                    this.overlay.hide();
-                }
-            }
-        },
-        methods: {
-            clearVals: function() {
-                // remove all value
-                this.$set('params', {});
-            },
-
-            /**
-             * 当二级筛选, 返回数据时, 调用该方法
-             * @param {[type]} cate [description]
-             * @param {[type]} val  [description]
-             */
-            setCateParams: function(cate, val) {
-                this.$set(`params.${cate}`, val);
-            },
-            okAction: function() {
-                bus.$emit('filter.change', {
-                    val: this.params,
-                    ref: this._uid
-                });
-            },
-            entrySub: function(key) {
-                const urlQuery = $.param({
-                    action: this.action,
-                    f_type: key,
-                    old_val: ''
-                }).concat('&', decodeURIComponent(location.search).replace(/^\?/, ''));
-
-                const url = ['/product/sub-filter', '?', urlQuery].join('');
-
-                // console.log(location.host+url);
-                yoho.goNewPage({url});
-            }
-        },
-        filters: {
-            unifyTxt: function(val, category) {
-                let txt = '';
-                let arr = [];
-                let foo = $.noop;
-
-
-                if ($.isArray(val)) { // [{categoryName,..},{}..]
-                    foo = (index, obj) => {
-                        arr.push(obj[category + 'Name']);
-                    };
-                }
-
-                $.each(val, foo);
-                txt = arr.join(',');
-                return txt;
-            },
-            txt: function(val) {
-                const dict = {
-                    color: 'Color颜色',
-                    gender: 'Gender性别',
-                    size: 'Size尺寸',
-                    brand: 'Brand品牌',
-                    priceRange: 'Price价格',
-                    groupSort: 'Category品类',
-                    discount: 'Sale折扣',
-                    style: 'Style风格',
-                    ageLevel: 'Age年龄'
-                };
-
-                return dict[val] || '';
-            }
-        },
-        created() {
-            const self = this;
-
-            this.overlay = new Overlay({
-                disableScrolling: true,
-                onClose: function() {
-                    self.isVisible = false;
-                }
-            });
-        }
-    };
-
-</script>
-<style>
-    @import "../../../scss/common/color";
-
-    .filter {
-        position: fixed;
-        z-index: 1001;
-        top: 0;
-        right: 0;
-        bottom: 0;
-        left: 20%;
-        background-color: #fff;
-        transform: translate3d(100%, 0, 0);
-        transition: all 0.3s 0.2s;
-        padding: 0 30px;
-
-        &.filter-open {
-            transform: translate3d(0, 0, 0);
-        }
-    }
-
-    .filter-actions {
-        font-size: 34px;
-        text-align: right;
-        padding: 45px 0;
-    }
-
-    .filter-action {
-        font-size: inherit;
-        margin-left: 40px;
-    }
-
-    .filter-actions,
-    .filter-cate {
-        border-bottom: 1px solid $grey;
-    }
-
-    .filter-cates {
-        list-style: none;
-        margin: 0;
-        padding: 0;
-    }
-
-    .filter-cate .icon-right {
-        margin-left: 24px;
-    }
-
-    .filter-cate,
-    .icon-right {
-        height: 118px;
-        line-height: 118px;
-    }
-
-    .filter-cate-label {
-        font-size: 36px;
-        font-weight: bold;
-    }
-
-    .filter-cate-val {
-        float: right;
-        font-size: 28px;
-    }
-
-    .filter-cate-val,
-    .filter-cate .icon {
-        color: $grey;
-    }
-
-</style>
diff --git a/public/vue/component/product/filter/filter-sub.vue.bk b/public/vue/component/product/filter/filter-sub.vue.bk
deleted file mode 100644
index ec65fbc..0000000
--- a/public/vue/component/product/filter/filter-sub.vue.bk
+++ /dev/null
@@ -1,85 +0,0 @@
-<template>
-    <div>
-        <brand-filter v-if="type === 'brand'" :data="data" :val.sync="val"></brand-filter>
-        <normal-filter v-else :data="data" :val.sync="val"></normal-filter>
-    </div>
-</template>
-<script>
-const $ = require('jquery');
-const parser = require('yoho-qs/parse');
-const tip = require('common/tip');
-const brandFilter = require('./brand.vue');
-const normalFilter = require('./normal.vue');
-
-module.exports = {
-    props: ['type', 'data', 'val'],
-    components: {
-        brandFilter,
-        normalFilter
-    },
-    watch: {
-        val: function(newV, oldV) {
-            console.log(`type: ${this.type}, value: ${newV}`);
-        }
-    },
-    created() {
-        const self = this;
-        const urlQuery = parser(decodeURIComponent(location.search.replace(/^\?/, '')));
-        const filterUrl = urlQuery.action;
-
-        this.type = urlQuery.f_type;
-        this.val = urlQuery.old_val;
-
-        delete urlQuery.f_type;
-        delete urlQuery.old_val;
-        delete urlQuery.action;
-
-        $.get(filterUrl, urlQuery)
-            .done(result => {
-                if (!result.data) {
-                    tip('加载失败~');
-                }
-                self.$set('data', result.data.filter[self.type]);
-            })
-            .fail(()=>{
-                tip('加载失败~');
-            });
-    }
-};
-</script>
-<style>
-@import "../../../../scss/common/_color.css";
-
-.filter-detail {
-    $w: 30px;
-    list-style: none;
-    margin: 0;
-    padding: 0;
-    font-size: 40px;
-    color: $grey;
-    .item,
-    .index {
-        margin-left: $w;
-        margin-right: $w;
-        border-bottom: 1px solid $division;
-    }
-    .index {
-        font-size: 32px;
-        font-weight: bold;
-        color: $black;
-        height: 60px;
-        line-height: 60px;
-    }
-    .item.active .item-inner {
-        color: $black;
-        background-color: #f6f6f6;
-    }
-    .item-inner {
-        margin-left: -$w;
-        margin-right: -$w;
-        padding: 0 $w;
-        height: 100px;
-        line-height: 100px;
-    }
-}
-</style>
diff --git a/public/vue/me/exchange.vue b/public/vue/me/exchange.vue
index 06bf324..78f5ff5 100644
--- a/public/vue/me/exchange.vue
+++ b/public/vue/me/exchange.vue
@@ -38,6 +38,7 @@
     const tip = require('common/tip');
     const bus = require('common/vue-bus');
     const modal = require('common/modal');
+    const interceptClick = require('common/intercept-click');
     const yoho = require('yoho');
 
     const productList = require('me/return/list.vue');
@@ -244,14 +245,13 @@
                         data
                     }).then(result => {
                         if (result.code === 200) {
-                            yoho.goNewPage({
-                                url: `/me/return/exchange/detail/${result.data.applyId}`,
-                                header: {
-                                    headerid: 1,
-                                    left: {
-                                        action: [location.protocol, '//', location.host , '/me/return'].join('')
-                                    }
-                                }
+                            let header = interceptClick.titleMap[1];
+
+                            header.left.action = location.origin + '/me/return'
+                            header.title.des = '换货状态';;
+                            return yoho.goNewPage({
+                                header: header,
+                                url: location.origin + `/me/return/exchange/detail/${result.data.applyId}`
                             });
                         } else {
                             modal.alert(result.message);
diff --git a/public/vue/me/fav-brand-list.vue b/public/vue/me/fav-brand-list.vue
index 69e0d10..3113e5e 100644
--- a/public/vue/me/fav-brand-list.vue
+++ b/public/vue/me/fav-brand-list.vue
@@ -37,6 +37,7 @@
 <script>
     const $ = require('jquery');
     const tip = require('common/tip');
+    const interceptClick = require('common/intercept-click');
     const yoho = require('yoho');
 
     module.exports = {
@@ -207,34 +208,17 @@
         },
         created: function() {
             let _this = this;
-
             yoho.addNativeMethod('editModel', function() {
                 _this.hideDelBth();
                 _this.editmodel = !_this.editmodel;
-                if (yoho.isApp) {
-                    yoho.goNewPage({
-                        header: {
-                            headerid: '5',
-                            left: {
-                                action: ''
-                            },
-                            ltitle: {
-                                des: '商品',
-                                action: location.origin + '/me/collection'
-                            },
-                            rtitle: {
-                                des: '品牌',
-                                action: location.origin + '/me/collection?tab=brand'
-                            },
-                            right: {
-                                des: _this.editmodel ? '完成' : '编辑',
-                                action: 'editModel'
-                            },
-                            defaultSelectedIndex: '1'
-                        },
-                        url: location.href
-                    });
-                }
+
+                let header = interceptClick.titleMap[5];
+
+                header.defaultSelectedIndex = '1';
+                header.right.des = _this.editmodel ? '完成' : '编辑';
+                return yoho.goPageView({
+                    header: header
+                });
             });
         }
     };
diff --git a/public/vue/me/fav-product-list.vue b/public/vue/me/fav-product-list.vue
index cf279fd..faf94c1 100644
--- a/public/vue/me/fav-product-list.vue
+++ b/public/vue/me/fav-product-list.vue
@@ -42,6 +42,7 @@
 <script>
     const $ = require('jquery');
     const tip = require('common/tip');
+    const interceptClick = require('common/intercept-click');
     const yoho = require('yoho');
 
     module.exports = {
@@ -228,30 +229,14 @@
             yoho.addNativeMethod('editModel', function() {
                 _this.hideDelBth();
                 _this.editmodel = !_this.editmodel;
-                if (yoho.isApp) {
-                    yoho.goNewPage({
-                        header: {
-                            headerid: '5',
-                            left: {
-                                action: ''
-                            },
-                            ltitle: {
-                                des: '商品',
-                                action: location.origin + '/me/collection'
-                            },
-                            rtitle: {
-                                des: '品牌',
-                                action: location.origin + '/me/collection?tab=brand'
-                            },
-                            right: {
-                                des: _this.editmodel ? '完成' : '编辑',
-                                action: 'editModel'
-                            },
-                            defaultSelectedIndex: '0'
-                        },
-                        url: location.href
-                    });
-                }
+
+                let header = interceptClick.titleMap[5];
+
+                header.defaultSelectedIndex = '0';
+                header.right.des = _this.editmodel ? '完成' : '编辑';
+                return yoho.goPageView({
+                    header: header
+                });
             });
         }
     };
diff --git a/public/vue/me/order-detail.vue b/public/vue/me/order-detail.vue
index 3b0e697..ac3f6c7 100644
--- a/public/vue/me/order-detail.vue
+++ b/public/vue/me/order-detail.vue
@@ -180,7 +180,7 @@
                         }
                     }).then(result => {
                         if (result.code === 200) {
-                            interceptClick('/me/order?type=1');
+                            interceptClick.intercept('/me/order?type=1');
                             return false;
                         } else {
                             tip(result.message);
@@ -213,7 +213,7 @@
             applyRefund() {
                 genderSel.show(function(item) {
                     if (item.url) {
-                        interceptClick(item.url);
+                        interceptClick.intercept(item.url);
                     }
                     return false;
                 });
diff --git a/public/vue/me/refund.vue b/public/vue/me/refund.vue
index 8f7162f..6b05b79 100644
--- a/public/vue/me/refund.vue
+++ b/public/vue/me/refund.vue
@@ -52,8 +52,8 @@
     const $ = require('jquery');
     const qs = require('yoho-qs');
     const modal = require('common/modal');
+    const interceptClick = require('common/intercept-click');
     const yoho = require('yoho');
-
     const productList = require('me/return/list.vue');
     const reasonConfig = require('me/return/reason');
 
@@ -159,14 +159,13 @@
                     data: this.submitData
                 }).then(result => {
                     if (result.code === 200) {
-                        yoho.goNewPage({
-                            url: `/me/return/refund/detail/${result.data.applyId}`,
-                            header: {
-                                headerid: 1,
-                                left: {
-                                    action: [location.protocol, '//', location.host , '/me/return'].join('')
-                                }
-                            }
+                        let header = interceptClick.titleMap[1];
+
+                        header.left.action = location.origin + '/me/return'
+                        header.title.des = '退货状态';;
+                        return yoho.goNewPage({
+                            header: header,
+                            url: location.origin + `/me/return/refund/detail/${result.data.applyId}`
                         });
                     } else {
                         modal.alert(result.message);
diff --git a/public/vue/me/refund/status.vue b/public/vue/me/refund/status.vue
index 7605ddf..91ac5d0 100644
--- a/public/vue/me/refund/status.vue
+++ b/public/vue/me/refund/status.vue
@@ -109,6 +109,7 @@
     const $ = require('jquery');
     const util = require('common/util');
     const tip = require('common/tip');
+    const interceptClick = require('common/intercept-click');
     const yoho = require('yoho');
 
     module.exports = {
@@ -141,25 +142,7 @@
                     }
                 }).then(function(data) {
                     if (data.code === 200) {
-                        const pageurl = '/me/return';
-
-                        if (yoho.isApp) {
-                            yoho.goNewPage({
-                                header: {
-                                    headerid: '1',
-                                    left: {
-                                        action: ''
-                                    },
-                                    title: {
-                                        des: '退/换货',
-                                        action: ''
-                                    }
-                                },
-                                url: location.origin + pageurl
-                            });
-                        } else {
-                            location.href = pageurl;
-                        }
+                        interceptClick.intercept('/me/return');
                     } else if (data.code === 400) {
                         tip(data.message);
                     } else {
--
libgit2 0.24.0