<!--
 * @Description: 
 * @Author: zhangwei
 * @Date: 2019-06-25 15:41:14
 * @LastEditTime: 2019-07-02 18:33:05
 * @LastEditors: zhangwei
 -->
<template>
  <div>
    <div v-for="(item,index) in items"
         :key="index">
       <div class="cItem" @click="onClickItem(item.name)">{{item.title}}</div>
    </div>
  </div>
</template>

<script>
    import YxNet from "../../../../utils/net/index"
    var Fly = require("flyio/dist/npm/wx")


    export default {
        data() {
            return {
                items: [{
                    name: 'setwx',
                    title: '设置微信、头条、百度平台'
                }, {
                    name: 'setap',
                    title: '设置支付宝平台'
                }, {
                    name: 'seturl',
                    title: '设置请求url'
                }, {
                    name: 'setHeaderToken',
                    title: '设置token'
                }, {
                    name: 'setHeader',
                    title: '设置头'
                }, {
                    name: 'get',
                    title: 'get请求'
                }, {
                    name: 'getlong',
                    title: 'get请求一直从缓存获取'
                }, {
                    name: 'cover',
                    title: '修改接口数据后覆盖缓存'
                }, {
                    name: 'post',
                    title: 'post请求'
                }, ],
            }
        },

        components: {},

        methods: {
            onClickItem(name) {
                if (name == 'setwx') {
                    var fly = new Fly
                    fly.config.timeout = 30000;
                    YxNet.init(fly)
                    console.log("设置wx成功")
                } else if (name == 'setap') {

                } else if (name == 'seturl') {
                    YxNet.setUrl("http://192.168.1.197:3000/")
                } else if (name == 'setHeaderToken') {
                    YxNet.setHeaderToken("aa")
                } else if (name == 'setHeader') {

                } else if (name == 'post') {
                    YxNet.netReq('post', 'api/v1/wx/getOpenId', {
                        code: '',
                        appid: '',
                    }).then((res) => {

                    }).catch((err) => {

                    })
                } else if (name == 'get') {
                    YxNet.netReq('get',
                        'fkc/product/product_category_list_cache_20', {
                            shop: 1
                        }
                    ).then((res) => {}).catch((err) => {})
                } else if (name == 'getlong') {
                    YxNet.netReq('get',
                        'fkc/product/product_category_list_cache_null', {
                            shop: 1
                        }
                    ).then((res) => {}).catch((err) => {})
                } else if (name == 'cover') {
                    YxNet.netReq('get',
                        'fkc/product/product_category_list_cache_null', {
                            shop: 1
                        }
                    ).then((res) => {
                        res[0].name = "zhangwei"
                        YxNet.coverInterfaceCache("fkc/product/product_category_list_cache_null", {
                            shop: 1
                        }, res)
                        setTimeout(() => {
                            YxNet.netReq('get',
                                'fkc/product/product_category_list_cache_null', {
                                    shop: 1
                                }
                            ).then((res) => {

                            }).catch((err) => {})
                        }, 1000)
                    }).catch((err) => {})
                }
            },
        },

        created() {
            // let app = getApp()
        }
    }
</script>

<style scoped>
    .cItem {
        width: 100%;
        line-height: 40px;
        padding-left: 10px;
        border-bottom: solid 1px #959595;
    }
</style>