<template>
  <view class="commonPageBox">
    <z-nav-bar title="设置"></z-nav-bar>
    <view class="contentBox commonPageContentBox">
      <view class="set_box">
        <list
          :dataList="dataList"
          @hancleClick="handleClickRightContent"
          label="title"
        >
          <template slot="rightSlot" slot-scope="slotProps">
            <text class="fdButtonBox aui-text-success">{{slotProps.row.content}}</text>
          </template>
        </list>
      </view>
      <view class="button_box" v-if="!visitorStatus">
        <u-button
          shape="square"
          type=""
          class="common_red_button button"
          size="medium"
          @click="handleClickButton(1)"
          >注销账号</u-button
        >
        <u-button
          shape="square"
          type=""
          class="common_grey_button button"
          size="medium"
          @click="handleClickButton(2)"
          >退出登录</u-button
        >
      </view>
    </view>

    <u-modal
      :show="signShow"
      :content="signContent"
      :showCancelButton="true"
      @cancel="signShow = false"
      @confirm="signOut"
    >
    </u-modal>
	<u-popup key="1" v-if="showCodeImg" :show="showCodeImg" :round="10" @close="closePup">
		<view class="box6">
			<text style="color: #999; margin-bottom: 20rpx;">点击图片后长按图片保存到手机，或使用微信扫描二维码添加客服企业微信</text>
			<image src="/static/qiyeWx.jpg" mode="widthFix" style="width: 100px; height: 100px; margin: 0 auto;"></image>
		</view>
	</u-popup>
  </view>
</template>

<script>
// #ifdef APP-PLUS
import updata from "@/uni_modules/uni-upgrade-center-app/utils/check-update";
// #endif
import list from "@/pages/component/commonComponents/list";
import $http from "@/config/requestConfig.js";
import { mapState, mapMutations } from "vuex";
export default {
  components: {
    list,
  },
  data() {
    return {
      signShow: false,
      signContent: "是否要退出登录？",
      playData: {},
      options: {},
      searchValue: "",
	  showCodeImg:false,
      twoCateList: [], // 二级分类标题
      titleList: [], // 方剂标题
      curOneCateIndex: 0, // 当前选中的一级分类
      curTwoCateIndex: 0, // 当前选中的二级分类
      searchList: [], // 搜索结果数组
      showSearchList: false,
      userMes: {}, // 用户信息
      searchDisable: false, // 搜索不可用
      limitShow: false,
      limitTitle: "提示",
      limitContent: "",
      scrollViewHeight: 0,
      dataList: [
        {
          title: "客服热线",
          content: "022-24142321",
          type: "tel",
        },
        {
          title: "客服邮箱",
          content: "appyilujiankang@sina.com",
          type: "email",
        },
        {
          title: "企业微信",
          content: "",
          type: "wxNumber",
        },
		{
          title: "版本检测",
          content: "",
          type: "checkVersion",
        }
      ],
      otherList: [
        {
          title: "关于我们",

          url: "/pages/mine/aboutUs/index",
          type: "pageJump",
        }
      ],
	  visitorStatus: null,  //游客身份访问set
    };
  },
  onLoad(options) {
	  if(options&&options.name){
		  this.visitorStatus = true;
	  }
  },
  computed: {
    ...mapState(["userInfo"]),
  },
  methods: {
    ...mapMutations(["setUserInfo"]),
	closePup(){
		this.showCodeImg = false
	},
	//退出
    signOut() {
      this.signShow = false;
      this.setUserInfo({ token: null });
	  uni.removeStorageSync('countryData');
      uni.redirectTo({
        url: "/pages/user/login",
      });
    },
    //注销账户
    logout() {
      let that = this;
      uni.showModal({
        title: "提示",
        content: "确定要注销当前账户吗？",
        success: function (res) {
          if (res.confirm) {
            uni.showModal({
              title: "提示",
              showCancel: false,
              content: `注销申请已提交成功,请联系客服进行后续操作：022-24142321`,
              success: function (res1) {
                if (res1.confirm) {
                  that.signOut();
                }
              },
            });
          } else if (res.cancel) {
            // 取消操作
          }
        },
      });
    },
	//选择
    handleClickButton(type) {
      switch (type) {
        case 1:
          this.logout();
          break;
        case 2:
          this.signShow = true;
          break;
      }
    },
	//list操作
    handleClickRightContent(row) {
      switch (row.type) {
        case "tel":
          this.$commonJS.handleMakingPhoneCalls(row.content);
          break;
        case "email":
          this.$commonJS.handleCopy(row.content, row.title);
          break;
        case "wxNumber":
		  this.showCodeImg = true
          break;
		case "checkVersion":
          this.getNewVersion()
          break;  
        case "pageJump":
          uni.navigateTo({
            url: row.url,
          });
          break;
      }
    },
	// 版本检测
	async getNewVersion(){
		// #ifdef APP-PLUS
		var info = await updata();
		if(info.result.code == 0){
			uni.showToast({
				title:info.result.message,
				icon:'none'
			})
		}
		// #endif
	},
  }
};
</script>

<style lang="scss" scoped>
@import "@/static/common.scss";

.box6 {
	padding: 20rpx;
		text-align: center;

		.title {
			font-size: 28rpx;
			margin: 10px 0;
		}

		.list {
			padding: 0 10px;
			padding-bottom: 20rpx;

			.item {
				font-size: 26rpx;
				color: #333;
				margin-bottom: 10rpx;
				padding-top:20rpx ;
				padding-bottom:20rpx ;
				line-height:40rpx;
				border-radius: 50rpx;
				border: 1px solid #eee;
			}

			.item.active {
				color: $themeColor;
				border: 1px solid $themeColor;
			}
		}

		.tbn {
			justify-content: center;
		}

		.buybtn { padding: 0 20rpx;
			background-color: #00d8df;
			margin: 0;
			margin-right: 20rpx;

			text {
				color: #fff;
			}
		}

		.saveBtnss {
			align-items: center;
			justify-content: center;
			height: 80rpx;
			overflow: hidden;
			border-radius: 50rpx;

			text {
				padding-left: 10rpx;
				font-size: 28rpx;

			}
		}

		.gouwuche {
			border: 1px solid #666;
			padding-right: 20rpx;
		}
	}

.searchList {
  .item {
    font-size: 28rpx;
    padding: 20rpx;
    border-bottom: 1px solid #dadbde;
  }
}

.scroll-view_H {
  background-color: #fff;
  white-space: nowrap;
  padding: 10rpx;
}

.scroll-Y {
  height: 100%;
}

.scroll-view_H {
  white-space: nowrap;
  width: 100%;
}

.scroll-view-item_H {
  display: inline-block;
  width: 100%;
}

.titleList {
  height: 100%;
}

.titleList2 {
  height: calc(100% - 170rpx);
}

/deep/.scroll-view-item:nth-child(2n-1) {
  background-color: transparent !important;
}

.fdButtonBox {
  color: #b0b0b0;
  float: right;
  padding: 4rpx 14rpx;
  font-size: 28rpx;
  font-weight: 500;
  line-height: 40rpx;
  display: inline-block;
  border-radius: 10rpx;
  box-sizing: border-box;
}

.commonPageBox {
  background-color: #f5f5f5;
}

/deep/.set_box {
  background-color: #fff;
  height: auto;

  padding: 20rpx;
  padding-bottom: 0;
  padding-top: 0;
}
/deep/.titleItem {
  line-height: 45rpx;
}
.button_box {
  width: 100%;
  position: fixed;
  bottom: 40rpx;
  padding: 20rpx 80rpx;

  .button {
    margin-top: 40rpx;
  }
}

/deep/.rightArrow {
  margin-top: 6rpx !important;
}
</style>
