猎豆优选小程序

setup.vue 7.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. <template>
  2. <view>
  3. <u-navbar class="navbar-wrap uni-navbar" :is-back="true" title="设置" :background="background" title-color="#ffffff" back-icon-color="#ffffff" />
  4. <view class="container">
  5. <view class="setup-item">
  6. <view class="setup-title">我的手机号</view>
  7. <view class="setup-item-con">
  8. <text>{{setUpInfo.phone}}</text>
  9. </view>
  10. </view>
  11. <view class="setup-item" @click="goPage('bindAlipay')">
  12. <view class="setup-title">我的支付宝</view>
  13. <view class="setup-item-con">
  14. <text>{{setUpInfo.alipay_account ? setUpInfo.alipay_account : '未录入'}}</text>
  15. <image class="jt-img" src="https://ld.726p.com/ldyx_static/imgs/rightArrow.png" mode="widthFix"></image>
  16. </view>
  17. </view>
  18. <view class="setup-item" @click="onClickCardId">
  19. <view class="setup-title">实名信息</view>
  20. <view class="setup-item-con">
  21. <text>{{cardId ? '修改' : '未录入'}}</text>
  22. <image class="jt-img" src="https://ld.726p.com/ldyx_static/imgs/rightArrow.png" mode="widthFix"></image>
  23. </view>
  24. </view>
  25. </view>
  26. <view class="container">
  27. <view class="setup-item" @click="onClickAuthorize">
  28. <view class="setup-title">淘宝授权</view>
  29. <view class="setup-item-con">
  30. <text>{{isAuthOrNo == 1 ? '已授权' : '未授权'}}</text>
  31. <image v-if="isAuthOrNo != 1" class="jt-img" src="https://ld.726p.com/ldyx_static/imgs/rightArrow.png" mode="widthFix"></image>
  32. </view>
  33. </view>
  34. </view>
  35. <view class="container">
  36. <view class="setup-item">
  37. <view class="setup-title">版本信息</view>
  38. <view class="setup-item-con">
  39. <text>{{version}}</text>
  40. </view>
  41. </view>
  42. </view>
  43. <view class="logout-button" :style="isIphoneX?'padding-bottom:40rpx':''" @click="logout">退出登录</view>
  44. <!-- 退出登录提示框 -->
  45. <u-modal v-model="showLogout" content="是否退出登录" :show-cancel-button="true" @confirm="confirmLogout"></u-modal>
  46. <!-- 淘宝授权弹框 -->
  47. <tbAuthorize v-if="tb_show" :tb_show="tb_show" @closeTask='tb_show = false'></tbAuthorize>
  48. <!-- 服务商 -->
  49. <serviceProvider :show="showService" @close="showService=false" hint="关于支付宝问题,请联系服务商!"></serviceProvider>
  50. </view>
  51. </template>
  52. <script>
  53. const app = getApp()
  54. import packageConfig from '../../../package.json'
  55. import tbAuthorize from '../../commonMoudle/tbAuthorize.vue'
  56. import serviceProvider from '@/components/serviceProvider.vue'
  57. export default {
  58. components:{
  59. serviceProvider,
  60. tbAuthorize
  61. },
  62. data() {
  63. return {
  64. background: app.globalData.navbarBackground,
  65. version: packageConfig.version,
  66. isIphoneX: app.globalData.isIphoneX,
  67. showLogout: false,
  68. setUpInfo: {},
  69. isAuthOrNo: 0,
  70. tb_show: false, // 淘宝授权
  71. showService: false, // 服务商
  72. // fun_version: app.globalData.fun_version,
  73. cardId: '',
  74. }
  75. },
  76. onShow() {
  77. this.getSetupData()
  78. this.getIsAuthOrNo()
  79. this.handleGetIdCard()
  80. },
  81. methods: {
  82. // 获取当前用户的实名认证信息
  83. async handleGetIdCard() {
  84. try {
  85. const url = this.$api.idCard_myCertification
  86. const params = {}
  87. uni.showLoading({ title: '加载中...', mask: true })
  88. const { data: res } = await this.$get(url, params)
  89. console.log('res => ', res)
  90. if (res && res.errno == 0 && res.rst.id_number) {
  91. this.cardId = res.rst.id_number
  92. } else {
  93. this.cardId = ''
  94. }
  95. } catch (error) {
  96. this.cardId = ''
  97. } finally {
  98. uni.hideLoading()
  99. }
  100. },
  101. onClickCardId() {
  102. const _this = this
  103. uni.showModal({
  104. title: '提示',
  105. content:`公民提现收入按照税法规定需要实名后进行个税申报,您提交的实名信息仅在个税申报时使用,请放心填写,若不需要提取佣金,可不做实名`,
  106. cancelText: '取消',
  107. confirmText: '去实名',
  108. success: function (res) {
  109. if (res.confirm) {
  110. uni.navigateTo({
  111. url: `/pages/subPackages/my/idCard`
  112. })
  113. }
  114. }
  115. });
  116. },
  117. // 点击淘宝授权
  118. onClickAuthorize () {
  119. if ( this.isAuthOrNo != 1 ) {
  120. const _this = this
  121. uni.showModal({
  122. title: '提示',
  123. content:`淘宝账号授权用于获取用户通过淘口令创建的订单信息,通过订单为您结算佣金,若不需要提取佣金,可跳过授权`,
  124. cancelText: '取消',
  125. confirmText: '去授权',
  126. success: function (res) {
  127. if (res.confirm) {
  128. // this.tb_show = true;
  129. _this.handleCopyTbUrl()
  130. }
  131. }
  132. });
  133. }
  134. },
  135. handleCopyTbUrl(){
  136. const token = uni.getStorageSync('token')
  137. let redirect_uri = `https://ld.726p.com/newh5/warrant.html?token=${token}&h5=applet`
  138. redirect_uri = encodeURIComponent(redirect_uri)
  139. this.$copyEvent({text:`https://oauth.taobao.com/authorize?response_type=code&client_id=25234720&redirect_uri=${redirect_uri}&state=3001&view=wap`,cb: () => {
  140. uni.showToast({
  141. icon: 'none',
  142. title: '链接已复制,请打开手机浏览器粘贴地址进行授权',
  143. duration: 3000,
  144. })
  145. }})
  146. },
  147. // 点击退出登录按钮
  148. logout () {
  149. this.showLogout = true
  150. },
  151. // 点击模态框,确认退出登录
  152. confirmLogout () {
  153. app.handleClearUserInfo() // 清空用户信息缓存
  154. uni.showToast({ title: '退出登录成功', icon: 'none' })
  155. uni.reLaunch({
  156. url: '/pages/home/home'
  157. });
  158. },
  159. //点击设置每项右侧剪头
  160. goPage (id) {
  161. const _this = this
  162. if(id === 'bindAlipay') { // 绑定支付宝
  163. uni.showModal({
  164. title: '提示',
  165. content:`支付宝账号仅用于用户提取佣金时收款使用,若无提取佣金需要,可跳过授权`,
  166. cancelText: '取消',
  167. confirmText: '去授权',
  168. success: function (res) {
  169. if (res.confirm) {
  170. _this.showService = true;
  171. }
  172. }
  173. });
  174. }
  175. },
  176. // 获取数据回显信息
  177. async getSetupData () {
  178. try {
  179. const url = this.$api.users_userInfoNew;
  180. const params = {}
  181. uni.showLoading({ title: '加载中...', mask: true })
  182. const { data: res } = await this.$postJSON(url, params)
  183. if (res && res.errno == 0) {
  184. this.setUpInfo = res.rst.data;
  185. let alipay_account = this.setUpInfo.alipay_account;
  186. this.setUpInfo.alipay_account = alipay_account && alipay_account.replace(alipay_account.substring(3,7), "****");
  187. } else {
  188. uni.showToast({ title: res.err || '操作失败', icon: 'none' })
  189. }
  190. } catch (error) {
  191. uni.showToast({ title: '服务器错误', icon: 'none' })
  192. } finally {
  193. uni.hideLoading()
  194. }
  195. },
  196. // 是否已完成淘宝授权
  197. async getIsAuthOrNo () {
  198. try{
  199. const url = this.$api.relationAuth_isAuthOrNo;
  200. const params = {};
  201. uni.showLoading({ title: '加载中...', mask: true })
  202. const { data: res } = await this.$postJSON(url, params)
  203. if (res && res.errno == 0) {
  204. this.isAuthOrNo = res.rst.flag;
  205. } else {
  206. uni.showToast({ title: res.err || '操作失败', icon: 'none' })
  207. }
  208. }catch(e){
  209. uni.showToast({ title: '服务器错误', icon: 'none' })
  210. } finally {
  211. uni.hideLoading()
  212. }
  213. }
  214. }
  215. }
  216. </script>
  217. <style scoped lang="scss">
  218. page{
  219. background-color: #f4f4f4;
  220. padding-bottom: 100rpx;
  221. }
  222. .container{
  223. background-color: #FFFFFF;
  224. margin-bottom: 20rpx;
  225. .setup-item{
  226. display: flex;
  227. align-items: center;
  228. justify-content: space-between;
  229. border-bottom: 2rpx solid #f4f4f4;
  230. padding:20rpx 40rpx;
  231. .setup-title{
  232. font-size: 32rpx;
  233. line-height: 40rpx;
  234. }
  235. .setup-item-con{
  236. font-size: 30rpx;
  237. line-height: 40rpx;
  238. color: #777777;
  239. display: flex;
  240. align-items: center;
  241. .jt-img{
  242. width: 26rpx;
  243. height: 26rpx;
  244. margin-left: 10rpx;
  245. }
  246. }
  247. }
  248. }
  249. .logout-button{
  250. position: fixed;
  251. bottom: 0;
  252. width: 100%;
  253. font-size: 32rpx;
  254. color: #F51400;
  255. line-height: 100rpx;
  256. background: #FFFFFF;
  257. text-align: center;
  258. }
  259. </style>