|
@@ -94,265 +94,16 @@
|
|
|
components: {},
|
|
|
data() {
|
|
|
return {
|
|
|
- title: '故事花园为您服务',
|
|
|
- app_index: [],
|
|
|
- story_info: {},
|
|
|
- platDiff: '',
|
|
|
+ title: '',
|
|
|
|
|
|
- num_people: 0,
|
|
|
- num_diamond: 0,
|
|
|
- showPop: false,
|
|
|
- popFrom: 'bottom',
|
|
|
- maskClick: true,
|
|
|
- isPlayingState: false,
|
|
|
-
|
|
|
- bg_show: false,
|
|
|
- show_sound: false,
|
|
|
- swiperIndex: 0,
|
|
|
- data_list: [{
|
|
|
- "title": "春晓",
|
|
|
- "author": "唐.白居易",
|
|
|
- "content": "春眠不觉晓,\n处处闻啼鸟。\n夜来风雨声,\n花落知多少。\n春眠不觉晓,\n处处闻啼鸟。\n夜来风雨声,\n花落知多少\n",
|
|
|
- "is_show": 1
|
|
|
- }],
|
|
|
- record_list: [],
|
|
|
- tid: 0,
|
|
|
- audio: null,
|
|
|
- record_id: 0,
|
|
|
}
|
|
|
},
|
|
|
onLoad() {
|
|
|
let self = this;
|
|
|
- // let dataString = uni.getStorageSync('home_dataMsg');
|
|
|
- // if(dataString && false) {
|
|
|
- // let dataList = JSON.parse(dataString);
|
|
|
- // this.app_index = dataList.app_index;
|
|
|
- // setTimeout(function() {
|
|
|
- // self.loadData(0);
|
|
|
- // },3000);
|
|
|
- // }else {
|
|
|
-
|
|
|
- // }
|
|
|
-
|
|
|
- // 全局挂载 音乐播放
|
|
|
- // #ifdef H5
|
|
|
- this.audio = uni.createInnerAudioContext();
|
|
|
- // #endif
|
|
|
- // #ifdef APP
|
|
|
- this.audio = uni.getBackgroundAudioManager();
|
|
|
- // #endif
|
|
|
-
|
|
|
- this.audio.onPlay(() => {
|
|
|
- console.log("----onPlay");
|
|
|
|
|
|
- });
|
|
|
- this.audio.onError(() => {
|
|
|
- console.log(res.errMsg);
|
|
|
- console.log(res.errCode);
|
|
|
- });
|
|
|
- this.audio.onPause(() => {
|
|
|
- console.log("----onPause");
|
|
|
-
|
|
|
- });
|
|
|
- this.audio.onStop(() => {
|
|
|
- console.log("----onStop");
|
|
|
- });
|
|
|
- this.audio.onEnded(() => {
|
|
|
- console.log("----onEnded");
|
|
|
- this.record_id = 0;
|
|
|
- });
|
|
|
- },
|
|
|
- onShow() {
|
|
|
- // uni.hideTabBar({
|
|
|
- // animation:false
|
|
|
- // })
|
|
|
- this.loadData(1);
|
|
|
- // this.showBottomPlayer();
|
|
|
},
|
|
|
- methods: {
|
|
|
- onSwiperChange(e) {
|
|
|
- this.swiperIndex = e.detail.current
|
|
|
- console.log("swiperIndex = " + this.swiperIndex);
|
|
|
- this.tid = this.data_list[this.swiperIndex].id;
|
|
|
- this.loadRecord();
|
|
|
-
|
|
|
- // this.$emit("change", e);
|
|
|
-
|
|
|
- },
|
|
|
- swiperChangeClick(e) {
|
|
|
-
|
|
|
- },
|
|
|
- start() {
|
|
|
- this.title = '录音已开始';
|
|
|
- console.log('start', new Date().getTime());
|
|
|
- },
|
|
|
- end(e) {
|
|
|
- this.title = '录音结束,停止录音,处理你得到的录音文件';
|
|
|
- console.log('end', e.tempFilePath);
|
|
|
- this.show_sound = false;
|
|
|
-
|
|
|
- uni.showLoading({
|
|
|
- title: '处理中'
|
|
|
- });
|
|
|
- let that = this;
|
|
|
- let uuid = getApp().globalData.postHeader.uuid;
|
|
|
- const uploadTask = uni.uploadFile({
|
|
|
- url: that.$apiHost + '/Gushi/upload', // post请求地址
|
|
|
- formData: {
|
|
|
- tid: that.tid,
|
|
|
- uuid: uuid
|
|
|
- },
|
|
|
- filePath: e.tempFilePath,
|
|
|
- name: 'file', // 待确认
|
|
|
- //下面header 如果在app上无法上传,则去掉注释
|
|
|
- // header: {
|
|
|
- // // 'Content-Type': 'multipart/form-data',
|
|
|
- // 'content-type': 'application/json'
|
|
|
- // },
|
|
|
- success: function(uploadFileRes) {
|
|
|
- let resdata = JSON.parse(uploadFileRes.data)
|
|
|
- console.log('Success1:', uploadFileRes);
|
|
|
- if (resdata.success == 'yes') {
|
|
|
- console.log('Success2:', resdata.url);
|
|
|
- // that.avator = resdata.url;
|
|
|
- that.loadData(2); //不翻页
|
|
|
- that.loadRecord();
|
|
|
- }
|
|
|
- // _self.imgsID.push(JSON.parse(uploadFileRes.data).data.fileId);
|
|
|
- // console.log('_self.imgsID:', _self.imgsID)
|
|
|
- },
|
|
|
- fail: function(uploadFileFail) {
|
|
|
- console.log('Error:', uploadFileFail.data);
|
|
|
- },
|
|
|
- complete: () => {
|
|
|
- console.log('Complete:');
|
|
|
- }
|
|
|
- });
|
|
|
- },
|
|
|
- cancel() {
|
|
|
- this.title = '录音取消,停止录音';
|
|
|
- console.log('cancel', new Date().getTime());
|
|
|
- },
|
|
|
- playRecord(item) {
|
|
|
- console.log('item', item.fileurl)
|
|
|
- this.record_id = item.id;
|
|
|
- this.audio.autoplay = false;
|
|
|
- this.audio.src = item.fileurl;
|
|
|
- this.audio.play();
|
|
|
- },
|
|
|
- onBack() {},
|
|
|
- onShowPopup(e) {
|
|
|
- this.showPop = e.detail.value
|
|
|
- },
|
|
|
- onMaskClick(e) {
|
|
|
- this.maskClick = e.detail.value
|
|
|
- },
|
|
|
- loadData(is_first) {
|
|
|
- console.log("this.globalData", getApp().globalData);
|
|
|
- let obj2 = {
|
|
|
- is_first: is_first
|
|
|
- }
|
|
|
- const postData = Object.assign({}, getApp().globalData.postHeader, obj2);
|
|
|
-
|
|
|
- console.log(this.$apiHost + '/Gushi/all');
|
|
|
-
|
|
|
- let that = this;
|
|
|
- uni.request({
|
|
|
- url: this.$apiHost + '/Gushi/all',
|
|
|
- data: postData,
|
|
|
- method: 'POST',
|
|
|
- header: {
|
|
|
- 'content-type': 'application/json',
|
|
|
- 'Cache-Control': 'no-cache',
|
|
|
- 'Access-Control-Allow-Origin': '*'
|
|
|
- },
|
|
|
- success: (res) => {
|
|
|
- console.log('data:', res.data);
|
|
|
- that.data_list = res.data.msg.list;
|
|
|
- that.num_people = res.data.msg.num_people;
|
|
|
- that.num_diamond = res.data.msg.num_diamond;
|
|
|
- if (is_first == 1) {
|
|
|
- that.data_list.map((item, index) => {
|
|
|
- if (item.is_show > 0) {
|
|
|
- that.swiperIndex = index
|
|
|
- that.tid = item.id;
|
|
|
- }
|
|
|
- });
|
|
|
- that.loadRecord();
|
|
|
- } else {
|
|
|
- that.data_list.map((item, index) => {
|
|
|
- if (that.tid == item.id) {
|
|
|
- that.swiperIndex = index
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- },
|
|
|
- complete() {
|
|
|
- uni.hideLoading()
|
|
|
- },
|
|
|
- fail: (e) => {
|
|
|
- console.log("e", e.errMsg)
|
|
|
- }
|
|
|
- });
|
|
|
- },
|
|
|
- loadRecord() {
|
|
|
- let obj2 = {
|
|
|
- tid: this.tid
|
|
|
- }
|
|
|
- console.log("this.obj2", obj2);
|
|
|
- const postData = Object.assign({}, getApp().globalData.postHeader, obj2);
|
|
|
- console.log(this.$apiHost + '/Gushi/all');
|
|
|
- let that = this;
|
|
|
- uni.request({
|
|
|
- url: this.$apiHost + '/Gushi/record',
|
|
|
- data: postData,
|
|
|
- method: 'POST',
|
|
|
- header: {
|
|
|
- 'content-type': 'application/json',
|
|
|
- 'Cache-Control': 'no-cache',
|
|
|
- 'Access-Control-Allow-Origin': '*'
|
|
|
- },
|
|
|
- success: (res) => {
|
|
|
- console.log('loadRecord:', res.data);
|
|
|
- that.record_list = res.data.msg.list;
|
|
|
- },
|
|
|
- fail: (e) => {
|
|
|
- console.log("e", e.errMsg)
|
|
|
- }
|
|
|
- });
|
|
|
- },
|
|
|
- likeThis(item) {
|
|
|
- let obj2 = {
|
|
|
- tid: item.id
|
|
|
- }
|
|
|
- console.log("tid", obj2);
|
|
|
- const postData = Object.assign({}, getApp().globalData.postHeader, obj2);
|
|
|
- let that = this;
|
|
|
- uni.request({
|
|
|
- url: this.$apiHost + '/Gushi/record_like',
|
|
|
- data: postData,
|
|
|
- method: 'POST',
|
|
|
- header: {
|
|
|
- 'content-type': 'application/json',
|
|
|
- 'Cache-Control': 'no-cache',
|
|
|
- 'Access-Control-Allow-Origin': '*'
|
|
|
- },
|
|
|
- success: (res) => {
|
|
|
- console.log('likeThis:', res.data);
|
|
|
- uni.showToast({
|
|
|
- title: res.data.str,
|
|
|
- icon: 'none'
|
|
|
- })
|
|
|
- if (res.data.status) {
|
|
|
- this.loadRecord();
|
|
|
- }
|
|
|
- },
|
|
|
- fail: (e) => {
|
|
|
- console.log("e", e.errMsg)
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
+ onShow() {},
|
|
|
+ methods: {}
|
|
|
}
|
|
|
</script>
|
|
|
|