uploaddata.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590
  1. <template>
  2. <view style="position: relative;">
  3. <!-- 胶囊 -->
  4. <mvBar :mysNavConfig="mysNavConfig"></mvBar>
  5. <view :style="{marginTop:navH}"></view>
  6. <view @click="toRecord()">
  7. <view style="display: flex;justify-content: center;">
  8. <image style="height: 60rpx;width: 60rpx;" src="../../static/img/icon-clock.png"></image>
  9. </view>
  10. <view style="display: flex;justify-content: center;">
  11. <p style="font-size: 30rpx;">查看修改/反馈记录</p>
  12. </view>
  13. </view>
  14. <view v-if="!loading && !onlyShow">
  15. <view style="margin: 40rpx;">
  16. <uni-forms :modelValue="formData" validate-trigger="bind" err-show-type="undertext" label-width="150">
  17. <uni-forms-item name="play_number" label="小眼睛阅读数/播放量">
  18. <uni-easyinput type="number" v-model="playsCount" :inputBorder="false" placeholder="输入"
  19. v-if="playsCountInfo === 1" @input="onInput1">
  20. </uni-easyinput>
  21. <uni-easyinput type="digit" v-model="playsCount" :inputBorder="false" placeholder="输入" v-else @input="onInput2">
  22. </uni-easyinput>
  23. <picker @change="bindPickerChange1" :value="index" :range="Range" range-key="label">
  24. <view>{{ playsLabel }}</view>
  25. </picker>
  26. </uni-forms-item>
  27. <uni-forms-item name="like_number" label="点赞数">
  28. <uni-easyinput type="number" v-model="likesCount" :inputBorder="false" placeholder="输入"
  29. v-if="likesCountInfo === 1" @input="onInput3">
  30. </uni-easyinput>
  31. <uni-easyinput type="digit" v-model="likesCount" :inputBorder="false" placeholder="输入" v-else @input="onInput4">
  32. </uni-easyinput>
  33. <picker @change="bindPickerChange2" :value="index2" :range="Range" range-key="label">
  34. <view>{{ likesLabel }}</view>
  35. </picker>
  36. </uni-forms-item>
  37. <uni-forms-item name="collect_number" label="收藏数">
  38. <uni-easyinput type="number" v-model="collectsCount" :inputBorder="false" placeholder="输入"
  39. v-if="collectsCountInfo === 1" @input="onInput5">
  40. </uni-easyinput>
  41. <uni-easyinput type="digit" v-model="collectsCount" :inputBorder="false" placeholder="输入" v-else @input="onInput6">
  42. </uni-easyinput>
  43. <picker @change="bindPickerChange3" :value="index3" :range="Range" range-key="label">
  44. <view>{{ collectsLabel }}</view>
  45. </picker>
  46. </uni-forms-item>
  47. <uni-forms-item name="comment_number" label="评论数">
  48. <uni-easyinput type="number" v-model="commentsCount" :inputBorder="false" placeholder="输入"
  49. v-if="commentsCountInfo === 1" @input="onInput7">
  50. </uni-easyinput>
  51. <uni-easyinput type="digit" v-model="commentsCount" :inputBorder="false" placeholder="输入" v-else @input="onInput8">
  52. </uni-easyinput>
  53. <picker @change="bindPickerChange4" :value="index4" :range="Range" range-key="label">
  54. <view>{{ commentsLabel }}</view>
  55. </picker>
  56. </uni-forms-item>
  57. </uni-forms>
  58. </view>
  59. <view style="margin: 0 40rpx;">
  60. <p style="font-size: 14px;margin-bottom: 20rpx;">上传小眼睛阅读数/播放量截图</p>
  61. <htz-image-upload :max="1" mediaType="image" name="file" :chooseNum="1" v-model="imageData"
  62. @chooseSuccess="ceshiChooseSuccess1">
  63. </htz-image-upload>
  64. </view>
  65. <view class="signup">
  66. <button type="default" class="but1" :loading="loading" @click="submit()">
  67. 提交数据</button>
  68. </view>
  69. </view>
  70. <view v-if="!loading && onlyShow">
  71. <view style="margin: 20rpx;">
  72. <view style="display: flex;margin-bottom: 10rpx;">
  73. <view style="width: 400rpx;">小眼睛阅读数/播放量</view>
  74. <view style="border: 1rpx;">{{formData.show_play_number}}</view>
  75. </view>
  76. <view style="display: flex;margin-bottom: 10rpx;">
  77. <view style="width: 400rpx;">点赞数</view>
  78. <view style="border: 1rpx;">{{formData.show_like_number}}</view>
  79. </view>
  80. <view style="display: flex;margin-bottom: 10rpx;">
  81. <view style="width: 400rpx;">收藏数</view>
  82. <view style="border: 1rpx;">{{formData.show_collect_number}}</view>
  83. </view>
  84. <view style="display: flex;margin-bottom: 10rpx;">
  85. <view style="width: 400rpx;">评论数</view>
  86. <view style="border: 1rpx;">{{formData.show_comment_number}}</view>
  87. </view>
  88. <!-- 图片 -->
  89. <view style="margin-top: 10rpx;">
  90. <p>小眼睛阅读数/播放量截图</p>
  91. <image :src="imageData" mode="aspectFit"></image>
  92. </view>
  93. </view>
  94. </view>
  95. </view>
  96. </template>
  97. <script>
  98. import mvBar from "@/components/mys_navBar/mysNavBar";
  99. import htzImageUpload from '@/components/htz-image-upload/htz-image-upload.vue';
  100. import getPolicyEncode from '@/components/obs/getPolicy.js';
  101. import getSignature from '@/components/obs/GetSignature.js';
  102. import {
  103. fansview
  104. } from '@/components/utils.js';
  105. export default {
  106. components: {
  107. mvBar,
  108. htzImageUpload,
  109. },
  110. data() {
  111. return {
  112. onlyShow: false,
  113. loading: true,
  114. navH: getApp().globalData.navHeight,
  115. taskId: "",
  116. dataStatus: "",
  117. imageData: [],
  118. formData: {
  119. play_number: "",
  120. like_number: "",
  121. collect_number: "",
  122. commet_number: "",
  123. show_play_number: "",
  124. show_like_number: "",
  125. show_collect_number: "",
  126. show_commet_number: "",
  127. },
  128. index1: 0,
  129. playsLabel: "个",
  130. playsCount: 0,
  131. playsCountInfo: 1,
  132. index2: 0,
  133. likesLabel: "个",
  134. likesCount: 0,
  135. likesCountInfo: 1,
  136. index3: 0,
  137. collectsLabel: "个",
  138. collectsCount: 0,
  139. collectsCountInfo: 1,
  140. index4: 0,
  141. commentsLabel: "个",
  142. commentsCount: 0,
  143. commentsCountInfo: 1,
  144. Range: [{
  145. value: 1,
  146. label: '个'
  147. },
  148. {
  149. value: 10000,
  150. label: '万'
  151. },
  152. {
  153. value: 100000000,
  154. label: '亿'
  155. }
  156. ],
  157. // rules: {
  158. // // 对play_number字段进行必填验证
  159. // play_number: {
  160. // rules: [{
  161. // required: true,
  162. // errorMessage: '10位以内的数字',
  163. // },
  164. // {
  165. // minLength: 1,
  166. // maxLength: 10,
  167. // errorMessage: '10位以内的数字',
  168. // }
  169. // ]
  170. // },
  171. // // 对like_number字段进行必填验证
  172. // like_number: {
  173. // rules: [{
  174. // required: true,
  175. // errorMessage: '10位以内的数字',
  176. // },
  177. // {
  178. // minLength: 1,
  179. // maxLength: 10,
  180. // errorMessage: '10位以内的数字',
  181. // }
  182. // ]
  183. // },
  184. // // 对collect_number字段进行必填验证
  185. // collect_number: {
  186. // rules: [{
  187. // required: true,
  188. // errorMessage: '10位以内的数字',
  189. // },
  190. // {
  191. // minLength: 1,
  192. // maxLength: 10,
  193. // errorMessage: '10位以内的数字',
  194. // }
  195. // ]
  196. // },
  197. // // 对comment_number字段进行必填验证
  198. // comment_number: {
  199. // rules: [{
  200. // required: true,
  201. // errorMessage: '10位以内的数字',
  202. // },
  203. // {
  204. // minLength: 1,
  205. // maxLength: 10,
  206. // errorMessage: '10位以内的数字',
  207. // }
  208. // ]
  209. // }
  210. // },
  211. mysNavConfig: {
  212. /* 开启单页显示首页图标 */
  213. isHome: true,
  214. /* 固定导航 */
  215. navFixed: true,
  216. /* 标题 (屏幕中心居中 两边图标中心居中使用slot center1) */
  217. navTitle: {
  218. text: "上传数据",
  219. color: "",
  220. fontSize: "32rpx", // px upx rpx
  221. fontWeight: "normal", // 100 - 700
  222. },
  223. btnType: "type2",
  224. onLeftClick: '',
  225. /* type2 按钮 */
  226. type2Config: {
  227. // 左图标
  228. leftPath: "/static/img/png2.png",
  229. // 右图标
  230. rightPath: "/static/img/png4.png",
  231. // 圆角
  232. radius: "40rpx",
  233. },
  234. },
  235. }
  236. },
  237. onLoad(options) {
  238. let data = options.textObj.replace(/""/g, "");
  239. data = JSON.parse(decodeURIComponent(data))
  240. this.taskId = data.taskId
  241. this.dataStatus = data.dataStatus
  242. this.getData()
  243. },
  244. methods: {
  245. async getData() {
  246. this.loading = true
  247. uni.showLoading({
  248. title: '加载中'
  249. });
  250. await this.$https.get('/youngee/c/t/g/get-unsubmit-task-data' +
  251. "?" +
  252. "task_id" +
  253. "=" +
  254. this.taskId)
  255. .then(res => {
  256. console.log(res)
  257. if (res.data.data != null) {
  258. this.onlyShow = true
  259. this.formData.play_number = res.data.data.play_number
  260. this.formData.like_number = res.data.data.like_number
  261. this.formData.collect_number = res.data.data.collect_number
  262. this.formData.comment_number = res.data.data.comment_number
  263. this.formData.show_play_number = fansview(this.formData.play_number)
  264. this.formData.show_like_number = fansview(this.formData.like_number)
  265. this.formData.show_collect_number = fansview(this.formData.collect_number)
  266. this.formData.show_comment_number = fansview(this.formData.comment_number)
  267. this.imageData.push(res.data.data.photo_url)
  268. }
  269. })
  270. uni.hideLoading();
  271. this.loading = false
  272. },
  273. toRecord() {
  274. var data = {
  275. taskId: this.taskId,
  276. };
  277. data = JSON.stringify(data)
  278. uni.navigateTo({
  279. url: '/pages/workspace/datarecord?textObj=' + encodeURIComponent(data)
  280. });
  281. },
  282. submit() {
  283. // 校验
  284. this.formData.play_number = this.playsCount * this.playsCountInfo
  285. if (parseInt(this.formData.plays_count) === 0) {
  286. uni.showToast({
  287. title: '请输入正确数量',
  288. icon: 'none'
  289. })
  290. return
  291. }
  292. this.formData.like_number = this.likesCount * this.likesCountInfo
  293. if (parseInt(this.formData.likes_count) === 0) {
  294. uni.showToast({
  295. title: '请输入正确数量',
  296. icon: 'none'
  297. })
  298. return
  299. }
  300. this.formData.collect_number = this.collectsCount * this.collectsCountInfo
  301. if (parseInt(this.formData.collects_count) === 0) {
  302. uni.showToast({
  303. title: '请输入正确数量',
  304. icon: 'none'
  305. })
  306. return
  307. }
  308. this.formData.comment_number = this.commentsCount * this.commentsCountInfo
  309. if (parseInt(this.formData.comments_count) === 0) {
  310. uni.showToast({
  311. title: '请输入正确数量',
  312. icon: 'none'
  313. })
  314. return
  315. }
  316. if (this.imageData.length == 0) {
  317. uni.showToast({
  318. title: "请上传正确的截图",
  319. icon: 'none'
  320. })
  321. return
  322. }
  323. let that = this
  324. uni.showModal({
  325. title: '提示',
  326. content: '提交后无法修改并进行审核,确认提交?',
  327. success: async function(res) {
  328. if (res.confirm) {
  329. // 调用添加数据接口
  330. await that.$https.post('/youngee/c/t/p/add-task-data', {
  331. task_id: that.taskId,
  332. play_number: that.formData.play_number,
  333. like_number: that.formData.like_number,
  334. collect_number: that.formData.collect_number,
  335. comment_number: that.formData.comment_number,
  336. photo_url: that.imageData[0],
  337. })
  338. .then(res => {
  339. console.log(res)
  340. })
  341. await that.$https.get('/youngee/c/t/g/submit-task-data' +
  342. "?" +
  343. "task_id" +
  344. "=" +
  345. that.taskId)
  346. .then(res => {
  347. console.log(res)
  348. })
  349. uni.navigateBack()
  350. } else if (res.cancel) {
  351. console.log('用户点击取消');
  352. }
  353. }
  354. });
  355. },
  356. ceshiChooseSuccess1(tempFilePaths, e) { //选择图片返回
  357. console.log('ceshiChooseSuccess', tempFilePaths, e);
  358. if (e == 0) {
  359. this.store = 'talent_upload/' + this.guid() + '.png'
  360. } else if (e == 1) {
  361. this.store = 'talent_upload/' + this.guid() + '.mp4'
  362. }
  363. /****************
  364. 以下代码是自定义上传逻辑,仅供参考
  365. ***************/
  366. this.imgUpload1(tempFilePaths);
  367. /*******************************/
  368. console.log("imgdata" + this.imageData)
  369. },
  370. imgUpload1(tempFilePaths) {
  371. let that = this
  372. console.log('imgUpload', tempFilePaths)
  373. let config = {
  374. AccessKeyId: 'IVW21DTGIIUBBAGXKK0Y', //AK
  375. SecretKey: 'Y01nEQNcLOATMw7uJwrk3yOdQZ2fqLhSnXcOKVDE', //SK
  376. EndPoint: 'https://horastar.obs.cn-east-3.myhuaweicloud.com', //上传文件的路径
  377. };
  378. let fileName = this.store; //指定上传到OBS桶中的对象名
  379. // let fileName = "talent_upload/icon-arrow-right.png"
  380. let OBSPolicy = { //设定policy内容
  381. "expiration": "2089-12-31T12:00:00.000Z",
  382. "conditions": [{
  383. "bucket": "horastar"
  384. }, //Bucket name
  385. // {"bucket": "goin"},
  386. {
  387. 'key': fileName
  388. }
  389. ]
  390. }
  391. let policyEncoded = getPolicyEncode(OBSPolicy); //计算policy编码值
  392. let signature = getSignature(policyEncoded, config.SecretKey); //计算signature
  393. uni.uploadFile({
  394. //url: config.EndPoint,
  395. url: config.EndPoint,
  396. filePath: tempFilePaths[0],
  397. name: 'file',
  398. formData: {
  399. 'AccessKeyID': config.AccessKeyId,
  400. 'policy': policyEncoded,
  401. 'signature': signature,
  402. 'key': fileName,
  403. },
  404. success: function(res) {
  405. console.log(res.statusCode); //打印响应状态码
  406. if (res.statusCode == '204') {
  407. that.imageData.push(config.EndPoint + '/' + fileName);
  408. console.log('上传图片成功', res)
  409. let obs_url = config.EndPoint + '/' + fileName; //用你自己的 bucket 名替换星号
  410. console.log(obs_url)
  411. // that.formData.home_img = obs_url
  412. uni.showToast({
  413. title: '上传成功',
  414. icon: '成功'
  415. });
  416. } else {
  417. console.log('上传图片失败', res)
  418. uni.showToast({
  419. title: '上传失败',
  420. icon: '失败'
  421. });
  422. }
  423. },
  424. fail: function(e) {
  425. console.log(e);
  426. uni.showToast({
  427. title: '上传失败22222',
  428. icon: '失败'
  429. });
  430. }
  431. })
  432. },
  433. guid() {
  434. return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
  435. var r = Math.random() * 16 | 0,
  436. v = c == 'x' ? r : (r & 0x3 | 0x8);
  437. return v.toString(16);
  438. });
  439. },
  440. // 量级选择
  441. bindPickerChange1: function(e) {
  442. this.index1 = e.detail.value;
  443. this.playsLabel = this.Range[this.index1].label
  444. this.playsCountInfo = this.Range[this.index1].value
  445. console.log(this.playsCountInfo, this.playsLabel)
  446. },
  447. // 量级选择
  448. bindPickerChange2: function(e) {
  449. this.index2 = e.detail.value;
  450. this.likesLabel = this.Range[this.index2].label
  451. this.likesCountInfo = this.Range[this.index2].value
  452. console.log(this.likesCountInfo, this.likesLabel)
  453. },
  454. // 量级选择
  455. bindPickerChange3: function(e) {
  456. this.index3 = e.detail.value;
  457. this.collectsLabel = this.Range[this.index3].label
  458. this.collectsCountInfo = this.Range[this.index3].value
  459. console.log(this.collectsCountInfo, this.collectsLabel)
  460. },
  461. // 量级选择
  462. bindPickerChange4: function(e) {
  463. this.index4 = e.detail.value;
  464. this.commentsLabel = this.Range[this.index4].label
  465. this.commentsCountInfo = this.Range[this.index4].value
  466. console.log(this.commentsCountInfo, this.commentsLabel)
  467. },
  468. onInput1(e) {
  469. console.log(e)
  470. e = e.replace(/\D/g, '')
  471. // e = (e.match(/^\d*(\.?\d{0,1})/g)[0]) || null
  472. // //重新赋值给input
  473. this.$nextTick(() => {
  474. this.playsCount = e
  475. })
  476. },
  477. onInput2(e) {
  478. console.log(e)
  479. e = (e.match(/^\d*(\.?\d{0,1})/g)[0]) || null
  480. // //重新赋值给input
  481. this.$nextTick(() => {
  482. this.playsCount = e
  483. })
  484. },
  485. onInput3(e) {
  486. console.log(e)
  487. e = e.replace(/\D/g, '')
  488. // e = (e.match(/^\d*(\.?\d{0,1})/g)[0]) || null
  489. // //重新赋值给input
  490. this.$nextTick(() => {
  491. this.likesCount = e
  492. })
  493. },
  494. onInput4(e) {
  495. console.log(e)
  496. e = (e.match(/^\d*(\.?\d{0,1})/g)[0]) || null
  497. // //重新赋值给input
  498. this.$nextTick(() => {
  499. this.likesCount = e
  500. })
  501. },
  502. onInput5(e) {
  503. console.log(e)
  504. e = e.replace(/\D/g, '')
  505. // e = (e.match(/^\d*(\.?\d{0,1})/g)[0]) || null
  506. // //重新赋值给input
  507. this.$nextTick(() => {
  508. this.collectsCount = e
  509. })
  510. },
  511. onInput6(e) {
  512. console.log(e)
  513. e = (e.match(/^\d*(\.?\d{0,1})/g)[0]) || null
  514. // //重新赋值给input
  515. this.$nextTick(() => {
  516. this.collectsCount = e
  517. })
  518. },
  519. onInput7(e) {
  520. console.log(e)
  521. e = e.replace(/\D/g, '')
  522. // e = (e.match(/^\d*(\.?\d{0,1})/g)[0]) || null
  523. // //重新赋值给input
  524. this.$nextTick(() => {
  525. this.commentsCount = e
  526. })
  527. },
  528. onInput8(e) {
  529. console.log(e)
  530. e = (e.match(/^\d*(\.?\d{0,1})/g)[0]) || null
  531. // //重新赋值给input
  532. this.$nextTick(() => {
  533. this.commentsCount = e
  534. })
  535. }
  536. }
  537. }
  538. </script>
  539. <style>
  540. /deep/ .uni-forms-item__content {
  541. display: flex !important;
  542. align-items: center !important;
  543. justify-content: space-between;
  544. }
  545. </style>
  546. <style lang="scss" scoped>
  547. .signup {
  548. box-shadow: 0rpx 5rpx 40rpx #ccc;
  549. width: 100%;
  550. position: fixed;
  551. bottom: 0rpx;
  552. display: flex;
  553. height: 90rpx;
  554. padding-top: 2%;
  555. background-color: #FFFFFF;
  556. }
  557. .but1 {
  558. width: 60%;
  559. background-color: #f2d22d;
  560. border-radius: 20rpx;
  561. font-size: 36rpx;
  562. line-height: 200%;
  563. letter-spacing: 10rpx;
  564. font-weight: 500;
  565. height: 80%;
  566. &.on {
  567. background-color: #C0C0C0;
  568. }
  569. }
  570. </style>