##上下架逻辑

### 在SentralService.js文件在中，在每次调用getProducts接口之后，执行setCurrentProducts方法
### 这种情况前端要确保每个页面都需要调用getProducts。且如果配置是天秤平台的情况下，在信息页点击提交按钮的时候（clickNextService）需要重新调用一次getProducts（不然进入天秤平台我们前端这边没有办法做上下架逻辑判断）

### setCurrentProducts方式返回的格式为 1-5的状态码， 分别对应 1--进入detail页面  2--进入下架页面  3--进入当前页面  4--停留下架页面  5--下架页面轮询进入产品列表页

####     getProducts: function () {
             var that = this;
             var urlParams = that.extractUrlParams(window.location.href);
             var deferred = Deferred();
             var dataToPost = {
                 source: urlParams.source,
                 organizationId: urlParams.organizationId,
                 productNo: urlParams.productNo
             };
             that.interfaces.postWithoutSource("/getProducts", dataToPost)
                 .then(function (data) {
                     if (data.code == 200) {
                         // data.data = [
                         //     {
                         //         color: "#ffffff",
                         //         companyId: "akgzjtest1",
                         //         endDate: "2019-09-15",
                         //         id: 12,
                         //         loginSource: "1",
                         //         product: "aki",
                         //         productName: "招商信诺安康万家重大疾病保险",
                         //         productNo: "701",
                         //         productUndershelf: true,
                         //         rank: 2,
                         //         remark: null,
                         //         source: "orion",
                         //         startDate: "2019-06-15"
                         //     }, {
                         //         color: "#ffffff",
                         //         companyId: "akgzjtest1",
                         //         endDate: "2019-09-15",
                         //         id: 12,
                         //         loginSource: "1",
                         //         product: "akg",
                         //         productName: "招商信诺安康万家团体重大疾病保险",
                         //         productNo: "702",
                         //         productUndershelf: true,
                         //         rank: 2,
                         //         remark: null,
                         //         source: "orion",
                         //         startDate: "2019-06-15"
                         //     }
                         // ];
                         avalon.log('data.data', data.data);
                         var result = that.setCurrentProducts(data.data, urlParams);// 1--进入detail页面  2--进入下架页面  3--进入当前页面  4--停留下架页面  5--下架页面轮询进入产品列表页
                         console.log(123, result, data.data);
                         if (result.index == 1) {
                             that.viewDetail(data.data[result.detail])
                         } else if (result.index == 2) {
                             location.href = result.productUndershelfUrl
                         } else if (result.index == 5) {
                             location.href = result.indexUrl
                         } else if (result.index == 3) {
                             deferred.resolve(data.data);
                         }
                     } else {
                         deferred.reject([{type: "modal", msg: data.message, code: ''}]);
                     }
                 })
                 .otherwise(function (res) {
                     deferred.reject('系统超时');
                 });
             return deferred.promise;
         }

####    setCurrentProducts: function (products, urlParams) {
           var result = {
               productUndershelfUrl: 'productUndershelf.html?organizationId=' + urlParams.organizationId,
               indexUrl: 'index.html?organizationId=' + urlParams.organizationId,
               index: 0,// 1--进入detail页面  2--进入下架页面  3--进入当前页面  4--停留下架页面  5--下架页面轮询进入产品列表页
               detail: 0,
           };
           if (products.length > 0) {
               var isCurrentProductLength = {
                   num: 0,
                   index: '',
               };
               for (var i = 0; i < products.length; i++) {
                   var datum = products[i];
                   if (datum.productUndershelf) {
                       isCurrentProductLength.num++
                   } else {
                       isCurrentProductLength.index = i;
                       result.detail = i
                   }
               }
               if (location.href.indexOf("/productUndershelf.html") != -1) {
                   if (isCurrentProductLength.num == products.length - 1) {
                       result.index = 1;
                       console.log("进入单独的detail页面")
                   } else if (isCurrentProductLength.num == products.length) {
                       result.index = 4;
                       console.log("进入下架页面01")
                   } else {
                       result.index = 5;
                       console.log("进入页面01")
                   }
               } else if (location.href.indexOf("/index.html") != -1) {
                   if (isCurrentProductLength.num == products.length - 1) {
                       result.index = 1;
                       console.log("进入单独的detail页面")
                   } else if (isCurrentProductLength.num == products.length) {
                       result.index = 2;
                       console.log("进入下架页面01")
                   } else {
                       result.index = 3;
                       console.log("进入页面02")
                   }
               } else if (location.href.indexOf("/myOrder.html") != -1) {
                   if (isCurrentProductLength.num == products.length) {
                       result.index = 2;
                       console.log("进入下架页面02")
                   } else {
                       result.index = 3;
                       console.log("进入页面02")
                   }
               } else {
                   var currentProduct = 0;
                   for (var i = 0; i < products.length; i++) {
                       var product = products[i];
                       if ((urlParams.productNo == product.productNo) && product.productUndershelf) {
                           result.index = 2;
                           console.log("进入下架页面03")
                       } else {
                           currentProduct++
                       }
                   }
                   if (currentProduct == products.length) {
                       result.index = 3;
                       console.log("进入页面03")
                   }
               }
           } else {
               console.log("进入下架页面04");
               result.index = 2;
           }
           return result
       }
