douyinbind.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671
  1. <template>
  2. <view style="position: relative;">
  3. <!-- 胶囊 -->
  4. <mvBar :mysNavConfig="mysNavConfig"></mvBar>
  5. <view :style="{marginTop:navH}"></view>
  6. <view class="home">
  7. <view class="card" v-if="!loading">
  8. <view class="head">
  9. <image src="https://horastar.obs.cn-east-3.myhuaweicloud.com/talent/pingtai2.png" mode="aspectFill">
  10. </image>
  11. <span>抖音账号绑定</span>
  12. </view>
  13. <view class="body">
  14. <view>
  15. <!-- 放用户信息 -->
  16. <view>
  17. <p>用户抖音平台头像昵称等信息展示</p>
  18. <p>用户抖音平台头像昵称等信息展示</p>
  19. <p>用户抖音平台头像昵称等信息展示</p>
  20. </view>
  21. <!-- 分割线 -->
  22. <view class="heng-line"></view>
  23. <!-- 点击弹窗 toggle(触发)-->
  24. <button class="btn1" @click="getqrcode('center')">
  25. 添加抖音账号</button>
  26. </view>
  27. </view>
  28. </view>
  29. </view>
  30. <!-- 普通弹窗 公众号-->
  31. <uni-popup ref="popup4" class="share" background-color="#fff" @change="change" :maskClick="true">
  32. <view class="popup-content" :class="{ 'popup-height': type === 'left' || type === 'right' }">
  33. <view class="sharepage">
  34. <view class="projecttext1">
  35. <span>抖音账号登录</span>
  36. </view>
  37. <view class="sharetxt">
  38. <text style="color:#9a9a9a ;">
  39. 截屏或下载二维码,使用抖音APP\n
  40. 打开[首页-搜索-扫一扫]后扫码进行
  41. </text>
  42. </view>
  43. <view class="sharemap">
  44. <image :src="qrcodeURL" style="width: 300rpx;height: 300rpx;" mode=""></image>
  45. <!-- <image :src="qrcodeURL" style="width: 300rpx;height: 300rpx;" mode=""></image> -->
  46. <!-- <image src="https://horastar.obs.cn-east-3.myhuaweicloud.com/talent/kefu.jpeg"
  47. style="width: 400rpx;height: 400rpx;" mode=""></image> -->
  48. </view>
  49. <view style="margin: 30rpx 0;">
  50. <button class="butmin1" size="mini" @tap="freshqrcode" :disabled="countdownTime > 0">
  51. {{ countdownTime > 0 ? `刷新二维码(${countdownTime}秒后到期)` : '刷新二维码 (已过期)' }}
  52. </button>
  53. </view>
  54. <!--
  55. ·同步账号基础信息及查看账号运营数据\n
  56. ·获得免费领样权限\n
  57. ·获得承接抖音悬赏任务权限\n
  58. ·为达人橱窗快速选品\n
  59. ·为直播带货快速选品\n
  60. ·样叽专属高佣商品,同一商品,更高佣金\n
  61. ·变现种草任务参与资质\n -->
  62. <view class="importentInfo1">
  63. <view class="sharetxt1" style="font-size: 22rpx;">
  64. <text style="white-space: pre-line; text-align: left;line-height: 1;">
  65. 登录成功后: \n
  66. ·同步账号基础信息及查看账号运营数据\n
  67. ·获得免费领样权限\n
  68. ·获得承接抖音悬赏任务权限\n
  69. ·为达人橱窗快速选品\n
  70. ·为直播带货快速选品\n
  71. ·样叽专属高佣商品,同一商品,更高佣金\n
  72. ·变现种草任务参与资质\n
  73. </text>
  74. </view>
  75. </view>
  76. <view style="margin: 30rpx 0;">
  77. <button class="butmin" size="mini" @tap="saveImage">下载二维码至手机</button>
  78. </view>
  79. </view>
  80. </view>
  81. </uni-popup>
  82. </view>
  83. </template>
  84. <script>
  85. import mvBar from "@/components/mys_navBar/mysNavBar";
  86. import htzImageUpload from '@/components/htz-image-upload/htz-image-upload.vue';
  87. import getPolicyEncode from '@/components/obs/getPolicy.js';
  88. import getSignature from '@/components/obs/GetSignature.js';
  89. export default {
  90. components: {
  91. mvBar,
  92. htzImageUpload,
  93. },
  94. data() {
  95. return {
  96. countdownTime: 300, // 初始倒计时时间(秒)
  97. intervalId: null, // 计时器 ID
  98. qrcodeURL: 'https://horastar.obs.cn-east-3.myhuaweicloud.com/talent/pingtai2.png', // 用来保存二维码URL的变量
  99. // qrcodeURL: '',
  100. navH: getApp().globalData.navHeight,
  101. hasClicked: false,
  102. loading: true,
  103. accountId: '',
  104. platform: {
  105. platform_id: '',
  106. platform_name: '',
  107. platform_icon: '',
  108. },
  109. isBind: true,
  110. imageData: [],
  111. formData: {
  112. platform_nickname: '',
  113. fans_count: '',
  114. home_page_url: '',
  115. home_page_capture_url: ''
  116. },
  117. // 二维码地址
  118. imageUrl: '',
  119. index: 0,
  120. fansLabel: "选择单位",
  121. fansCount: null,
  122. fansCountInfo: 1,
  123. fansRange: [{
  124. value: 1,
  125. label: '个'
  126. },
  127. {
  128. value: 10000,
  129. label: '万'
  130. },
  131. {
  132. value: 100000000,
  133. label: '亿'
  134. }
  135. ],
  136. mysNavConfig: {
  137. /* 开启单页显示首页图标 */
  138. isHome: true,
  139. /* 固定导航 */
  140. navFixed: true,
  141. /* 标题 (屏幕中心居中 两边图标中心居中使用slot center1) */
  142. navTitle: {
  143. text: "社媒账号绑定",
  144. color: "",
  145. fontSize: "32rpx", // px upx rpx
  146. fontWeight: "normal", // 100 - 700
  147. },
  148. btnType: "type2",
  149. onLeftClick: '',
  150. /* type2 按钮 */
  151. type2Config: {
  152. // 左图标
  153. leftPath: "/static/img/png2.png",
  154. // 右图标
  155. rightPath: "/static/img/png4.png",
  156. // 圆角
  157. radius: "40rpx",
  158. },
  159. }, // 密码登录校验规则
  160. bindRules: {
  161. name: {
  162. rules: [{
  163. required: true,
  164. errorMessage: '请输入昵称'
  165. }]
  166. },
  167. home_img: {
  168. rules: [{
  169. required: true,
  170. errorMessage: '请上传主页截图',
  171. }]
  172. }
  173. },
  174. urlRegList: [
  175. /(.*)http(s?)\:\/\/((www\.)?)(xiaohongshu\.com)(.*)/,
  176. /(.*)http(s?)\:\/\/((www\.)?)((v\.)?)(douyin\.com)(.*)/,
  177. /(.*)http(s?)\:\/\/((www\.)?)((m\.)?)(weibo\.(com|cn))(.*)/,
  178. /(.*)http(s?)\:\/\/((www\.)?)((v|kpfshanghai)\.m\.chenzhongtech\.com)(.*)/,
  179. /(.*)http(s?)\:\/\/((www\.)?)(b23\.tv)(.*)/,
  180. /(.*)http(s?)\:\/\/((www\.)?)((m\.)?)(dianping\.(com|cn))(.*)/,
  181. /(.*)http(s?)\:\/\/((www\.)?)(zhihu\.com)(.*)/,
  182. ]
  183. }
  184. },
  185. onReady() {},
  186. async onShow() {},
  187. async onLoad(options) {
  188. this.platform.platform_id = parseInt(options.platform_id)
  189. if (options.account_id) {
  190. this.accountId = parseInt(options.account_id)
  191. this.isBind = false
  192. }
  193. this.loading = true;
  194. uni.showLoading({
  195. title: '加载中'
  196. });
  197. await this.getinfo();
  198. if (!this.isBind) {
  199. await this.getaccount()
  200. };
  201. this.loading = false;
  202. uni.hideLoading();
  203. },
  204. methods: {
  205. // 获得二维码
  206. async getqrcode(type) {
  207. this.type4 = type;
  208. this.$refs.popup4.open(type);
  209. this.loading = true;
  210. uni.showLoading({
  211. title: '加载中',
  212. })
  213. this.startCountdown();
  214. // 从后端中请求二维码图片展示出来
  215. //达人id在后端通过session获取
  216. await this.$https.get('/youngee/c/t/g/display-qrcode').then(res => {
  217. console.log("resisjjjj",res)
  218. this.qrcodeURL = res.data.data;
  219. console.log("url:", this.qrcodeURL);
  220. })
  221. this.loading = false;
  222. uni.hideLoading();
  223. },
  224. // 倒计时结束才能点击
  225. freshqrcode() {
  226. if (this.intervalId != null) {
  227. clearInterval(this.intervalId);
  228. this.countdownTime = 300;
  229. }
  230. //重新设置倒计时时间
  231. this.countdownTime = 300; // 重置为 300 秒
  232. // 启动倒计时计时器
  233. this.startCountdown();
  234. this.qrcodeURL = 'https://horastar.obs.cn-east-3.myhuaweicloud.com/talent/pingtai2.png'
  235. // 启动倒计时计时器
  236. this.$https.get('/displayqrcode').then(res => {
  237. this.qrcodeURL = res.data;
  238. console.log("url:", this.qrcodeURL);
  239. })
  240. },
  241. startCountdown() {
  242. // 每秒减少剩余时间
  243. this.intervalId = setInterval(() => {
  244. if (this.countdownTime > 0) {
  245. this.countdownTime--;
  246. }
  247. }, 1000); // 每秒执行一次
  248. },
  249. //unipop出现/消失自动触发
  250. change(e) {
  251. if(this.loading){
  252. this.loading = false;
  253. uni.hideLoading();
  254. }
  255. if (this.intervalId != null) {
  256. clearInterval(this.intervalId);
  257. this.countdownTime = 300;
  258. }
  259. this.qrcodeURL = 'https://horastar.obs.cn-east-3.myhuaweicloud.com/talent/pingtai2.png'
  260. console.log("ddcpdd")
  261. },
  262. // 保存图片
  263. async saveImage() {
  264. // showToast('保存成功')
  265. wx.downloadFile({
  266. url: 'https://horastar.obs.cn-east-3.myhuaweicloud.com/talent/pingtai2u',
  267. success: function(res) {
  268. wx.saveImageToPhotosAlbum({
  269. filePath: res.tempFilePath,
  270. success: function(data) {
  271. wx.showToast({
  272. title: "保存成功",
  273. icon: "success",
  274. duration: 2000
  275. })
  276. },
  277. fail: function(err) {
  278. console.log(err);
  279. },
  280. complete(res) {
  281. console.log(res);
  282. }
  283. })
  284. }
  285. })
  286. },
  287. closepop() {
  288. this.$refs.popup4.close()
  289. },
  290. // 默认信息表,获取平台logo
  291. getinfo() {
  292. return this.$https.get('/youngee/c/g/get-info-tables')
  293. .then(res => {
  294. let list = res.data.data.ThirdPlatform
  295. for (var i = 0; i < list.length; ++i) {
  296. if (list[i].id == this.platform.platform_id) {
  297. this.platform.platform_icon = list[i].platform_icon
  298. this.platform.platform_name = list[i].platform_name
  299. }
  300. }
  301. })
  302. },
  303. getaccount() {
  304. return this.$https.get('/youngee/c/t/g/get-talent-account')
  305. .then(res => {
  306. console.log(res)
  307. if (res.data.code !== -3) {
  308. this.account = res.data.data
  309. this.imageData = []
  310. for (var i = 0; i < this.account.length; i++) {
  311. if (this.platform.platform_id == this.account[i].platform_id) {
  312. this.hasClicked = true
  313. this.formData.platform_nickname = this.account[i].platform_nickname
  314. this.formData.fans_count = this.account[i].fans_count
  315. this.formData.home_page_url = this.account[i].home_page_url
  316. this.imageData.push(this.account[i].home_page_capture_url);
  317. if (this.formData.fans_count >= 100000000) {
  318. this.index = 2
  319. this.fansCountInfo = this.fansRange[this.index].value;
  320. this.fansLabel = this.fansRange[this.index].label;
  321. this.fansCount = (this.formData.fans_count / 100000000).toFixed(1)
  322. } else if (this.formData.fans_count >= 10000) {
  323. this.index = 1
  324. this.fansCountInfo = this.fansRange[this.index].value;
  325. this.fansLabel = this.fansRange[this.index].label;
  326. this.fansCount = (this.formData.fans_count / 10000).toFixed(1)
  327. } else {
  328. this.index = 0
  329. this.fansCountInfo = this.fansRange[this.index].value;
  330. this.fansLabel = this.fansRange[this.index].label;
  331. this.fansCount = this.formData.fans_count
  332. }
  333. }
  334. }
  335. }
  336. })
  337. },
  338. exit() {
  339. uni.navigateBack()
  340. },
  341. // 粉丝量量级选择
  342. bindPickerChange: function(e) {
  343. if (this.index !== e.detail.value) {
  344. this.fansCount = null
  345. }
  346. this.index = e.detail.value;
  347. this.fansLabel = this.fansRange[this.index].label
  348. this.fansCountInfo = this.fansRange[this.index].value
  349. },
  350. ceshiChooseSuccess(tempFilePaths, e) { //选择图片返回
  351. console.log('ceshiChooseSuccess', tempFilePaths, e);
  352. if (e == 0) {
  353. this.store = 'talent_upload/' + this.guid() + '.png'
  354. // this.store = 'talent_upload/icon-whole-pipline.png'
  355. // this.store = 'youngee/talent_upload/icon-edit.2png'
  356. } else if (e == 1) {
  357. this.store = 'talent_upload/' + this.guid() + '.mp4'
  358. }
  359. /****************
  360. 以下代码是自定义上传逻辑,仅供参考
  361. ***************/
  362. this.imgUpload(tempFilePaths);
  363. /*******************************/
  364. },
  365. imgUpload(tempFilePaths) {
  366. let that = this
  367. let config = {
  368. AccessKeyId: 'IVW21DTGIIUBBAGXKK0Y', //AK
  369. SecretKey: 'Y01nEQNcLOATMw7uJwrk3yOdQZ2fqLhSnXcOKVDE', //SK
  370. EndPoint: 'https://horastar.obs.cn-east-3.myhuaweicloud.com', //上传文件的路径
  371. };
  372. let fileName = this.store; //指定上传到OBS桶中的对象名
  373. let OBSPolicy = { //设定policy内容
  374. "expiration": "2089-12-31T12:00:00.000Z",
  375. "conditions": [{
  376. "bucket": "horastar"
  377. }, //Bucket name
  378. // {"bucket": "goin"},
  379. {
  380. 'key': fileName
  381. }
  382. ]
  383. }
  384. let policyEncoded = getPolicyEncode(OBSPolicy); //计算policy编码值
  385. let signature = getSignature(policyEncoded, config.SecretKey); //计算signature
  386. uni.uploadFile({
  387. //url: config.EndPoint,
  388. url: config.EndPoint,
  389. filePath: tempFilePaths[0],
  390. name: 'file',
  391. formData: {
  392. 'AccessKeyID': config.AccessKeyId,
  393. 'policy': policyEncoded,
  394. 'signature': signature,
  395. 'key': fileName,
  396. },
  397. success: function(res) {
  398. console.log("res", res); //打印响应状态码
  399. if (res.statusCode == 204) {
  400. // that.imageData.push(config.EndPoint + '/' + fileName);
  401. let obs_url = config.EndPoint + '/' + fileName; //用你自己的 bucket 名替换星号
  402. that.imageData.push(obs_url)
  403. that.formData.home_page_capture_url = obs_url
  404. uni.showToast({
  405. title: '上传成功',
  406. icon: '成功'
  407. });
  408. } else {
  409. uni.showToast({
  410. title: '上传失败',
  411. icon: '失败'
  412. });
  413. }
  414. },
  415. fail: function(e) {
  416. console.log(e);
  417. uni.showToast({
  418. title: '上传失败',
  419. icon: '失败'
  420. });
  421. }
  422. })
  423. },
  424. guid() {
  425. return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
  426. var r = Math.random() * 16 | 0,
  427. v = c == 'x' ? r : (r & 0x3 | 0x8);
  428. return v.toString(16);
  429. });
  430. },
  431. onInput(e) {
  432. console.log(e)
  433. e = (e.match(/^\d*(\.?\d{0,1})/g)[0]) || null
  434. // //重新赋值给input
  435. if (e < 0 || e > 9999.9) {
  436. uni.showToast({
  437. title: '请输入[1,9999.9]区间内的数',
  438. icon: 'none'
  439. })
  440. console.log('请输入[1,9999.9]区间内的数')
  441. }
  442. this.$nextTick(() => {
  443. this.fansCount = (e > 0 && e <= 9999.9) ? e : null
  444. })
  445. },
  446. onInput1(e) {
  447. // 验证是否是纯数字
  448. const isNumber = /^\d*$/.test(e)
  449. // 过滤非数字
  450. e = e.replace(/\D/g, '')
  451. if (!isNumber || e < 0 || e > 9999) {
  452. uni.showToast({
  453. title: '请输入[0,9999]区间的整数',
  454. icon: 'none'
  455. })
  456. console.log('请输入[0,9999]区间的整数')
  457. }
  458. this.$nextTick(() => {
  459. this.fansCount = (e >= 0 && e <= 9999 && e.match(/^\d*/g)[0]) ? e : null
  460. })
  461. }
  462. },
  463. }
  464. </script>
  465. <style>
  466. /deep/ .share .uni-popup .uni-popup__wrapper {
  467. width: 70% !important;
  468. border-radius: 15rpx !important;
  469. }
  470. </style>
  471. <style lang="scss" scoped>
  472. .importentInfo1 {
  473. margin-left: 59rpx;
  474. background-color: #efefef;
  475. border-radius: 8px;
  476. height: 370rpx;
  477. width: 400rpx;
  478. }
  479. // 主体样式
  480. .card {
  481. padding: 24rpx;
  482. margin-top: 30rpx;
  483. border: 1rpx solid #F0D232;
  484. background-color: #ffffff;
  485. margin: 0 10rpx;
  486. }
  487. .head {
  488. padding-top: 5%;
  489. padding: 0 0 0 1%;
  490. height: 80rpx;
  491. margin-top: 2%;
  492. }
  493. .head span {
  494. color: #333333;
  495. font-size: 80%;
  496. font-weight: 550;
  497. text-indent: 2em;
  498. }
  499. .head image {
  500. vertical-align: middle;
  501. width: 50rpx;
  502. height: 50rpx;
  503. display: inline-block;
  504. padding-right: 14rpx;
  505. }
  506. .home-link {
  507. /deep/.uni-easyinput__content-input {
  508. background-color: #EBEBEB;
  509. border-radius: 15rpx;
  510. }
  511. }
  512. .heng-line {
  513. margin-top: 60rpx;
  514. margin-bottom: 50rpx;
  515. border-bottom: 1rpx solid #DCDCDC;
  516. }
  517. .signupbtn p {
  518. font-size: 30rpx;
  519. }
  520. .exit-btn {
  521. width: 200rpx;
  522. text-align: center;
  523. padding: 10rpx 30rpx;
  524. background-color: #C0C0C0;
  525. border: 0;
  526. border-radius: 10rpx;
  527. color: #FFFFFF;
  528. font-size: 30rpx;
  529. line-height: 180%;
  530. }
  531. .btn1 {
  532. margin: 30rpx;
  533. font-size: 35rpx;
  534. color: #000;
  535. background-color: #F0D232;
  536. border: none;
  537. border-radius: 0;
  538. }
  539. //弹窗
  540. .share {
  541. text-align: center;
  542. line-height: 10rpx;
  543. margin-top: 10rpx;
  544. }
  545. .sharepage {
  546. // width: 90%;
  547. margin: 0 auto;
  548. // position: relative;
  549. }
  550. /deep/ .share.uni-popup .uni-popup__wrapper {
  551. width: 70%;
  552. border-radius: 15rpx;
  553. }
  554. .projecttext1 {
  555. // padding-top: 5%;
  556. padding: 0 0 0 1%;
  557. margin: 5% 0;
  558. text-align: center;
  559. }
  560. .projecttext1 image {
  561. vertical-align: middle;
  562. width: 80rpx;
  563. height: 80rpx;
  564. display: inline-block;
  565. padding-right: 14rpx;
  566. }
  567. .sharemap {
  568. margin: 0 auto;
  569. text-align: center;
  570. // margin-top: 15%;
  571. // margin-bottom: 15%;
  572. }
  573. .sharemap image {
  574. width: 400rpx;
  575. height: 400rpx;
  576. }
  577. .sharetxt {
  578. height: 100rpx;
  579. display: flex;
  580. flex-direction: column;
  581. align-items: center;
  582. justify-content: center;
  583. }
  584. .sharetxt1 {
  585. padding: 10rpx;
  586. height: 345rpx;
  587. display: flex;
  588. flex-direction: column;
  589. align-items: center;
  590. justify-content: center;
  591. }
  592. .sharetxt text {
  593. font-size: 24rpx;
  594. text-align: left;
  595. line-height: 20rpx
  596. }
  597. .butmin {
  598. // height: 48rpx;
  599. width: 380rpx;
  600. height: 65rpx;
  601. background-color: #FCCF41;
  602. line-height: 60rpx;
  603. font-weight: bold;
  604. }
  605. .butmin1 {
  606. // height: 48rpx;
  607. width: 400rpx;
  608. background-color: #ffffff;
  609. border: #000000 10rpx;
  610. line-height: 48rpx;
  611. color: #FCCF41;
  612. font-weight: bold;
  613. font-size: 20rpx;
  614. }
  615. </style>