chat.vue 89 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260
  1. <template>
  2. <view>
  3. <view style="color: #000;">
  4. <tn-nav-bar backgroundColor="#fff">{{ zhuangtai }}
  5. <!-- <view slot="right" class='tn-custom-nav-bar__back' @click="goBack"> -->
  6. <!-- #ifdef H5 -->
  7. <!-- <text class='tn-icon tn-icon-align' style="font-size: 42rpx;margin-right: 22rpx;"></text> -->
  8. <!-- #endif -->
  9. <!-- #ifdef MP-WEIXIN -->
  10. <!-- <text class='tn-icon tn-icon-align' style="font-size: 42rpx;font-weight: bold;color: #26b3a0d6;"></text> -->
  11. <!-- #endif -->
  12. <!-- </view> -->
  13. </tn-nav-bar>
  14. <view :style="{ height: tobheight + 'px' }"></view>
  15. </view>
  16. <view class="content" @touchmove="touchmove">
  17. <view class="msg-list">
  18. <view class="row">
  19. <block>
  20. <view class="other">
  21. <view class="left" v-if="appInfo.is_show_gpt_avatar_nickname == 1"
  22. @click="switchmodel = true">
  23. <u-image :src="
  24. homeTemplate.mode && homeTemplate.mode[0].img_file != null &&homeTemplate.mode[0].img_file.path
  25. ? homeTemplate.mode[0].img_file.path
  26. : '/static/images/open.png'
  27. " mode="aspectFill" radius="5" width="40" height="40"></u-image>
  28. </view>
  29. <view class="right">
  30. <view class="username">
  31. <view class="name"></view>
  32. <view class="time">{{ homeTemplate.mode && homeTemplate.mode.length>0&& homeTemplate.mode[0].img_file != null && homeTemplate.mode[0].name
  33. ?homeTemplate.mode[0].name :'ai问答机器人' }}</view>
  34. </view>
  35. <view class="bubble">
  36. <view class="content mytheme">
  37. <view style="font-size: 32rpx;">您可以点击下方示例直接提问......</view>
  38. <block v-for="(item, index) in homeTemplate.hot" :key="index">
  39. <view class="ask" @click="send(item.text)">{{ item.text }}</view>
  40. </block>
  41. <view @click="commontemplate" class="tn-flex align-center"
  42. style="justify-content: flex-end;margin-top: 15rpx;margin-bottom: 15rpx;">
  43. <view style="color: #9e9e9e;margin-right: 10rpx;">换一换</view>
  44. <u-icon name="reload" color="#9e9e9e" size="18"></u-icon>
  45. </view>
  46. <u-button size="small" @click="switchmodel = true" type="primary"
  47. text="切换角色"></u-button>
  48. </view>
  49. </view>
  50. </view>
  51. </view>
  52. </block>
  53. </view>
  54. <block v-for="(row, index) in talkList" :key="index" :id="'msg' + row.id">
  55. <view class="row">
  56. <block>
  57. <view class="my" v-if="row.fromid == userInfo.id">
  58. <view class="left">
  59. <view class="username">
  60. <view class="name">{{ row.nickname }}</view>
  61. </view>
  62. <view class="u-flex u-flex-nowrap justify-between" style="align-items: center;">
  63. <!-- v-if="row.content !='该问题已被隐藏!'" -->
  64. <view class="mycopy u-flex justify-center align-center">
  65. <u-icon @click="copyText(index)"
  66. name="file-text" top="1" color="#fff" size="18"></u-icon>
  67. </view>
  68. <view v-if="row.type == 1" class="bubble mytheme" style="color: #fff;">
  69. <!-- <rich-text :nodes="row.content" @longtap="copy" :data-text="row.content"
  70. selectable="true"></rich-text> -->
  71. <!-- <zero-markdown-view :themeColor="themeColor"
  72. :markdown="row.content"></zero-markdown-view> -->
  73. <u-parse :content="row.content" scrollTable :tag-style="parse_style" selectable style="width: 100%;"></u-parse>
  74. <!-- <mp-html :content="row.content" /> -->
  75. </view>
  76. </view>
  77. </view>
  78. <view class="right">
  79. <u-image :src="row.avatar ? row.avatar : '/static/images/head.jpg'" mode="aspectFill"
  80. radius="5" width="42" height="42"></u-image>
  81. </view>
  82. </view>
  83. <!-- GPT -->
  84. <view class="other" v-if="row.fromid != userInfo.id">
  85. <view class="left" v-if="appInfo.is_show_gpt_avatar_nickname == 1"
  86. @click="switchmodel = true">
  87. <u-image :src="row.avatar" mode="aspectFill" radius="5" width="42"
  88. height="42"></u-image>
  89. </view>
  90. <view class="right">
  91. <view class="username" v-if="appInfo.is_show_gpt_avatar_nickname == 1">
  92. <view class="name"></view>
  93. <view class="time">{{ row.nickname }}</view>
  94. </view>
  95. <view v-if="row.type == 1" class="bubble"
  96. style="display: block;position: relative;">
  97. <view class="mytheme">
  98. <!-- <zero-markdown-view
  99. v-if="(row.done && row.content.indexOf('```') != -1) || (row.done && row.content.indexOf('/*') != -1 || row.content.indexOf('---') != -1)"
  100. :themeColor="themeColor" :markdown="row.content"></zero-markdown-view>
  101. <text v-else @longtap="copy"
  102. :data-text="row.content">{{ row.content.replace(/^\s+|\s+$/g, '') }}</text>
  103. <text v-if="row.content == '正在思考中...'">{{ second }}s</text>
  104. <text class="flash" v-if="row.show_flash">│</text> -->
  105. <view class="u-flex align-center flex-wrap">
  106. <text
  107. v-if="row.content == '正在思考中...'||row.content == '请等我几秒钟,正在输入回答...'">{{row.content}}</text>
  108. <!-- <zero-markdown-view v-else :themeColor="themeColor"
  109. :markdown="row.content"></zero-markdown-view> -->
  110. <u-parse v-else :content="row.content" :tag-style="parse_style" scrollTable selectable style="width: 100%;"></u-parse>
  111. <!-- <mp-html v-else :content="row.content" /> -->
  112. <text v-if="row.content == '正在思考中...'">{{ second }}s</text>
  113. <view
  114. :style="{marginLeft: row.content == '正在思考中...'||row.content == '请等我几秒钟,正在输入回答...'?20+'rpx':0+'rpx',marginTop: row.content != '正在思考中...'||row.content != '请等我几秒钟,正在输入回答...'?10+'rpx':0+'rpx'}"
  115. v-if="row.show_flash">
  116. <view style="margin-top: -5rpx;">
  117. <u-loading-icon size="17" mode="circle" color="#00ca88" :duration="300"></u-loading-icon>
  118. </view>
  119. </view>
  120. </view>
  121. </view>
  122. <view v-if="row.done && !row.donec" class="tn-flex align-center justify-between operate">
  123. <view @click="send(talkList[index-1].content)" hover-class="hoversubmit"
  124. class="tn-flex justify-center align-center dialogue" style="margin-right: 10px;">
  125. <u-icon name="reload" top="1" color="#fff" size="18"></u-icon>
  126. <!-- <view class="duplicate">复制回答</view> -->
  127. </view>
  128. <view class="tn-flex align-center">
  129. <view @click="copyText(index)" hover-class="hoversubmit"
  130. class="tn-flex justify-center align-center dialogue">
  131. <u-icon name="file-text" top="1" color="#fff" size="18"></u-icon>
  132. <!-- <view class="duplicate">复制回答</view> -->
  133. </view>
  134. <view @click="createPoster(index)" hover-class="hoversubmit"
  135. class="tn-flex justify-center align-center dialogue" style="margin-left: 10px;">
  136. <u-icon name="share-square" top="1" color="#fff" size="18"></u-icon>
  137. <!-- <view class="share">分享对话</view> -->
  138. </view>
  139. <view v-if="appInfo.is_vop&&appInfo.is_vop == 1" class="eliseaudio">
  140. <elise-audio @aittsjob="aittsjob" :audioId="'audioId'+index"
  141. :url="row.audiolink" audioColor="#68d7bb" :durationS="5"
  142. :content="row.backups" :index="index" :cancel="cancel"></elise-audio>
  143. </view>
  144. </view>
  145. </view>
  146. </view>
  147. <!-- <view v-if="row.type == 2" class="bubble"
  148. style="display: block;position: relative;">
  149. <view class="u-flex align-center">
  150. <text style="margin-right: 20rpx;">{{row.content}}</text>
  151. <u-loading-icon size="17"></u-loading-icon>
  152. </view>
  153. </view> -->
  154. <!-- <view v-if="row.type == 3" class="bubbleimg">
  155. <image @click="preview(index)" :src="row.img" mode="aspectFill"></image>
  156. </view> -->
  157. </view>
  158. </view>
  159. </block>
  160. </view>
  161. </block>
  162. </view>
  163. <view class="bottomheight"></view>
  164. <view class="env"></view>
  165. </view>
  166. <view class="box-2">
  167. <view class="flex_col">
  168. <view class="flex_grow">
  169. <!-- height="45" -->
  170. <u--textarea height="45" @blur="blurinput" @focus="focusinput" fixed :showConfirmBar="false"
  171. v-model="content" :placeholder="'请输入您的问题...'"
  172. :maxlength="-1" border="none" :cursorSpacing="80"></u--textarea>
  173. </view>
  174. <!-- <u-icon name="close-circle-fill" color="#ededed"
  175. size="20"></u-icon> -->
  176. <u-icon v-if="appInfo.is_vop&&appInfo.is_vop == 1" @click="openmicrophone" name="mic" color="#ff9800"
  177. size="30"></u-icon>
  178. <button class="send"
  179. @click.prevent="send(content)">{{'发送'}}</button>
  180. </view>
  181. </view>
  182. <u-popup :show="showexpand" zIndex="1" mode="bottom" bgColor="transparent" :overlay="false"
  183. @close="showexpand = false">
  184. <scroll-view class="scroll-view_H" scroll-x="true">
  185. <view class="expand u-flex">
  186. <view @click="showsheet = true" class="surplus u-flex align-center">
  187. <u-icon name="grid-fill" color="#26b3a0d6" size="18" top="1"></u-icon>
  188. <!-- <view class="item">
  189. {{currentmodel}}{{userData.is_validity>0&&!this.showchat4&&userData.vip_info&&userData.vip_info.gpt35_times>0?' - 今日限量:'+userData.vip_info.gpt35_used+'/'+userData.vip_info.gpt35_times:''}}
  190. </view> -->
  191. <view v-if="showchat4" class="item">{{currentmodel}}{{userData.vip_info&&userData.is_validity>0?(userData.vip_info.gpt4_type == 'time'?' - 今日':' - 会员')+'剩余提问:'+(userData.vip_info.gpt4_times == -1?'无限量':userData.vip_info.gpt4_times-userData.vip_info.gpt4_used+'次'):''}} ></view>
  192. <view v-else class="item">{{currentmodel}}{{userData.vip_info&&userData.is_validity>0?(userData.vip_info.gpt35_type == 'time'?' - 今日':' - 会员')+'剩余提问:'+(userData.vip_info.gpt35_times == -1?'无限量':userData.vip_info.gpt35_times-userData.vip_info.gpt35_used+'次'):''}} ></view>
  193. </view>
  194. <!-- <block v-if="!showchat4"> -->
  195. <navigator @click="getroute"
  196. :url="isLogin ?'/pages/user/member/member?id=2':'/pages/user/signin'"
  197. class="surplus u-flex align-center"
  198. v-if="appInfo.time_member && appInfo.time_member == 1">
  199. <u-icon name="clock-fill" color="#607d8b" size="18" top="1"></u-icon>
  200. <view class="item">
  201. 会员套餐:{{ userData.is_validity == 1 ? (userData.vip_time == 9999?'永久':userData.countdown+'天') : '0天' }}
  202. </view>
  203. </navigator>
  204. <!-- </block> -->
  205. <block v-if="appInfo.number_member">
  206. <navigator @click="getroute"
  207. :url="isLogin ?'/pages/user/member/member?id=1':'/pages/user/signin'"
  208. class="surplus u-flex align-center" v-if="appInfo.number_member == 1">
  209. <u-icon name="question-circle-fill" color="#ff9800" size="18" top="1"></u-icon>
  210. <view class="item">
  211. {{appInfo.number_alias?appInfo.number_alias+':':'点数:'}}{{ userData.coin ? userData.coin : 0 }}
  212. </view>
  213. </navigator>
  214. </block>
  215. <block v-else>
  216. <navigator @click="getroute"
  217. :url="isLogin ?'/pages/user/member/member?id=1':'/pages/user/signin'"
  218. class="surplus u-flex align-center">
  219. <u-icon name="question-circle-fill" color="#ff9800" size="18" top="1"></u-icon>
  220. <view class="item">
  221. {{appInfo.number_alias?appInfo.number_alias+':':'点数:'}}{{ userData.coin ? userData.coin : 0 }}
  222. </view>
  223. </navigator>
  224. </block>
  225. <!-- <view class="surplus">分享好友赚佣金</view> -->
  226. <navigator @click="getroute" :url="isLogin ?'/pages/user/member/member?id=3':'/pages/user/signin'"
  227. class="surplus u-flex align-center">
  228. <u-icon name="more-circle-fill" color="#2979ff" size="18" top="1"></u-icon>
  229. <view class="item">免费领{{appInfo.number_alias?appInfo.number_alias:'点数'}}</view>
  230. </navigator>
  231. <view class="surplus u-flex align-center" style="background: #fff0;padding: 1rpx;">
  232. </view>
  233. </view>
  234. </scroll-view>
  235. </u-popup>
  236. <!-- <wike-skeleton count="4" type="user" v-if="homeTemplate.length === 0"></wike-skeleton> -->
  237. <u-no-network></u-no-network>
  238. <!-- <navigator v-if="is_commission == 1" class="neckBtn_view" url="/pages/user/commission/index">
  239. <text class="free_view">分享</text>
  240. 赚佣金
  241. </navigator> -->
  242. <u-action-sheet @select="selectClick" :round="10" :actions="sheetlist" :title="titlesheet" :show="showsheet"
  243. safeAreaInsetBottom @close="showsheet = false" cancelText="关闭"></u-action-sheet>
  244. <!-- <u-popup :show="showPoster" mode="bottom" :round="10" safeAreaInsetTop @close="showPoster = false">
  245. <view class="poster">
  246. <wike-painter :board="posterObj" @success="posterSuccess" ref="painter"></wike-painter>
  247. <view class="footer-btn">
  248. <view class="" @click="showPoster = false">退出</view>
  249. <view class="save" @click="toSave">保存/分享</view>
  250. </view>
  251. </view>
  252. </u-popup> -->
  253. <u-popup :show="showPoster" mode="bottom" @close="showPoster = false">
  254. <scroll-view scroll-y="true" :style="{maxHeight: (posterheight) +'px'}">
  255. <wike-painter :board="posterObj" @done="posterSuccess" ref="painter"></wike-painter>
  256. <view style="height: 78px;"></view>
  257. <view class="dygbhg" >
  258. <view class="whole" @click="showPoster = false">取消</view>
  259. <view class="distinguish" @click="toSave">保存/分享</view>
  260. </view>
  261. </scroll-view>
  262. </u-popup>
  263. <u-popup :show="soundrecording" mode="bottom" :round="20" safeAreaInsetTop @close="soundrecording = false">
  264. <view class="soundrecording u-flex justify-center">
  265. <view v-if="showlongpress" class="waveform">
  266. <image :src="'https://s1.voicecloud.cn/activity/imeVoiceShare/img/yuyin.gif'" mode="aspectFill">
  267. </image>
  268. </view>
  269. <view class="operation u-flex">
  270. <!-- <view class="affirm">
  271. <image src="/static/tf-speech-recognizer/cancel.png"></image>
  272. </view> -->
  273. <view @touchstart="startrecording" @touchend="stoprecording" class="longpress"
  274. hover-class="hoversubmit">
  275. <!-- <image disabled src="/static/tf-speech-recognizer/recording.png"></image> -->
  276. <u-icon name="mic" color="#fff" size="35"></u-icon>
  277. </view>
  278. <!-- <view class="affirm">
  279. <image src="/static/tf-speech-recognizer/confirm.png"></image>
  280. </view> -->
  281. </view>
  282. <view class="discriminate">长按识别语音</view>
  283. </view>
  284. </u-popup>
  285. <wike-loading-page :isLoading="isLoading"></wike-loading-page>
  286. <!-- 生成的图片 -->
  287. <u-popup type="center" mode="center">
  288. <view class="poster-img">
  289. <text @click="closePopup"></text>
  290. <!-- <image :src="path" mode="" @click="previewImg"></image> -->
  291. <!-- #ifdef H5 -->
  292. <view class="">长按图片保存到手机</view>
  293. <!-- #endif -->
  294. <!-- #ifndef H5 -->
  295. <view class="">点击图片保存到手机</view>
  296. <!-- #endif -->
  297. </view>
  298. </u-popup>
  299. <u-popup :show="switchmodel" @close="switchmodel = false" :round="15" closeable>
  300. <view class="select u-flex justify-center"><text>选择角色</text></view>
  301. <scroll-view scroll-y="true"
  302. :style="{ height: homeTemplate.mode&&homeTemplate.mode.length > 6 ? 700 + 'rpx' : 'auto' }">
  303. <block v-for="(item, index) in homeTemplate.mode" :key="index">
  304. <view class="u-flex justify-between model_view">
  305. <u-avatar
  306. :src="item.img_file != null&&item.img_file.path?item.img_file.path:'/static/images/open.png'"
  307. shape="square" mode="aspectFill" size="60"></u-avatar>
  308. <view class="modelname">
  309. <view class="name">{{ item.name }}</view>
  310. <view class="modeldetails">{{ item.intro }}</view>
  311. </view>
  312. <view @click="onselect(index)" class="modelselect"
  313. :style="{ background: selectornot == index ? '#9e9e9e' : '' }">
  314. {{ selectornot == index ? '已选择' : '选择' }}
  315. </view>
  316. </view>
  317. </block>
  318. <view style="height: 30rpx;"></view>
  319. </scroll-view>
  320. </u-popup>
  321. <wike-model v-if="signShow" :authorize="false" :title="signTitle" btnText="立即获取" @save="signSign"
  322. @close="signShow = false"></wike-model>
  323. <wike-modal-qrcode :qrcode="gzhqrcode" :showconcern="showconcern" @concernclose="concernclose"></wike-modal-qrcode>
  324. </view>
  325. </template>
  326. <script>
  327. const {
  328. marked
  329. } = require('marked');
  330. import hljs from "highlight.js";
  331. import "highlight.js/scss/atom-one-dark.scss";
  332. import {
  333. Socket
  334. } from 'dgram';
  335. import {
  336. mapMutations,
  337. mapActions,
  338. mapState,
  339. mapGetters
  340. } from 'vuex';
  341. import {
  342. apiurl,
  343. } from '@/common/request/request';
  344. import {
  345. API_STEROOT,
  346. } from '@/common/request/request';
  347. import MumuRecorder from '@/uni_modules/mumu-recorder/components/mumu-recorder/mumu-recorder.vue';
  348. import eliseAudio from '@/components/elise-audio/elise-audio.vue';
  349. import {
  350. toPx,
  351. base64ToPath,
  352. pathToBase64,
  353. isBase64,
  354. sleep,
  355. getImageInfo
  356. } from '@/components/wike-painter/utils';
  357. // #ifdef H5
  358. import Recorder from 'recorder-core';
  359. import 'recorder-core/src/engine/wav'
  360. // #endif
  361. let down, delay;
  362. let interstitialAd = null,
  363. timer,
  364. time2,
  365. timingr;
  366. // const innerAudioContext = uni.createInnerAudioContext();
  367. const recorderManager = uni.getRecorderManager();
  368. export default {
  369. components: {
  370. MumuRecorder,
  371. eliseAudio,
  372. // #ifdef H5
  373. Recorder
  374. // #endif
  375. },
  376. data() {
  377. return {
  378. // API_ROOT: API_ROOT,
  379. signShow: false,
  380. signTitle: '',
  381. talkList: [],
  382. toid: 1,
  383. content: '',
  384. thecontent: '',
  385. image: '',
  386. // scrollTop: 999999,
  387. // scrollAnimation: false,
  388. // text1: ['您好,ChatGPT为您服务', '长按对话即可复制'],
  389. tobheight: 45,
  390. zhuangtai: 'AI智能问答机器人',
  391. platform: this.$platform.get(),
  392. // isFlash:false,
  393. showPoster: false,
  394. posterObj: {},
  395. switchmodel: false,
  396. selectornot: 0,
  397. // modeldata: [],
  398. qrcode: '',
  399. haddressurl: '',
  400. haddresssk: '',
  401. // scrollToView: '',
  402. question_index: 0,
  403. answer_index: 0,
  404. themeColor: '#007AFF',
  405. // codeBgColor: '#26B3A0',
  406. showexpand: true,
  407. second: 11,
  408. showanswer: false,
  409. h5question: '',
  410. followornot: true,
  411. // eights: false,
  412. spmplatform: 0,
  413. is_commission: 0,
  414. timing: 30,
  415. showcontext: true,
  416. showfetch: true,
  417. //倒计时
  418. showdirect: true,
  419. //通道
  420. thoroughfare: 0,
  421. //弹出录音
  422. soundrecording: false,
  423. //是否长按
  424. showlongpress: false,
  425. //音频
  426. innerAudioContextsrc: '',
  427. //取消音频加载
  428. cancel: false,
  429. //第一次录
  430. firstrecording: 0,
  431. //加载
  432. isLoading: true,
  433. //模型
  434. showsheet: false,
  435. //当前模型
  436. currentmodel: '',
  437. titlesheet: '切换模型',
  438. //是否为gpt4模型
  439. showchat4: false,
  440. //模型数据
  441. // #ifdef MP-WEIXIN
  442. sheetlist: [{
  443. index: 1,
  444. name: 'ChatGPT 3.5',
  445. subname: "高效沟通·简单提问",
  446. color: '#26b3a0d6',
  447. disabled: false
  448. },
  449. ],
  450. // #endif
  451. // #ifdef H5
  452. sheetlist: [
  453. {
  454. index: 0,
  455. name: 'ChatGPT 4.0',
  456. subname: "超级高效沟通·简单提问",
  457. disabled: false
  458. },
  459. {
  460. index: 1,
  461. name: 'ChatGPT 3.5',
  462. subname: "高效沟通·简单提问",
  463. color: '#26b3a0d6',
  464. disabled: false
  465. },
  466. ],
  467. // #endif
  468. // 消耗
  469. plan: {},
  470. chatgpturl: '',
  471. showconcern:false,
  472. gzhqrcode:'',
  473. posterheight:'',
  474. parse_style: {
  475. // 字符串的形式
  476. p: 'margin-bottom:0rpx;',
  477. // 一级标题
  478. h1: `
  479. margin:25px 0;
  480. font-size: 24px;
  481. text-align: center;
  482. font-weight: bold;
  483. color: #00ca88;
  484. padding:3px 10px 1px;
  485. border-bottom: 2px solid #00ca88;
  486. border-top-right-radius:3px;
  487. border-top-left-radius:3px;
  488. `,
  489. // 二级标题
  490. h2: `
  491. margin:40px 0 20px 0;
  492. font-size: 20px;
  493. text-align:center;
  494. color:#00ca88;
  495. font-weight:bolder;
  496. padding-left:10px;
  497. border:1px solid #00ca88;
  498. `,
  499. // 三级标题
  500. h3: `
  501. margin:30px 0 10px 0;
  502. font-size: 18px;
  503. color: #00ca88;
  504. padding-left:10px;
  505. border-left:3px solid #00ca88;
  506. `,
  507. // 四级标题
  508. h4: `
  509. margin:20px 0 10px 0;
  510. font-size: 16px;
  511. color: #00ca88;
  512. padding-left:10px;
  513. border-left:3px solid #00ca88;
  514. `,
  515. // 五级标题
  516. h5: `
  517. margin:10px 0 10px 0;
  518. font-size: 14px;
  519. color: #00ca88;
  520. padding-left:10px;
  521. border-left:3px solid #00ca88;
  522. `,
  523. // 六级标题
  524. h6: `
  525. margin:10px 0 10px 0;
  526. font-size: 12px;
  527. color: #00ca88;
  528. padding-left:10px;
  529. border-left:3px solid #00ca88;
  530. `,
  531. ul: 'margin:24rpx;color: #555;',
  532. ol: 'margin:12rpx;color:#555;',
  533. li: `
  534. margin: 12rpx 0;
  535. color: #555;
  536. `,
  537. // 链接
  538. a: `
  539. color: #00ca88;`,
  540. // 加粗
  541. strong: `
  542. font-weight: border;
  543. color: #00ca88;
  544. `,
  545. // 斜体
  546. em: `
  547. color: #00ca88;
  548. letter-spacing:0.3em;
  549. `,
  550. // code: 'width:90%;',
  551. // pre: 'white-space: pre;overflow: auto;background: #2d2d2d;border-radius: 4rpx;border: none;color: #ccc;margin: 12rpx;padding:20rpx;',
  552. // 'pre code': 'margin:0;padding:0;background: none;color: #ccc;',
  553. blockquote: 'padding: 15rpx;margin:0 0 12rpx 0;border-radius: 6rpx;color: #555;border-left: 4px solid #dddddd;',
  554. hr: `height:1px;padding:0;border:none;text-align:center;background-image:linear-gradient(to right,rgba(248,57,41,0),${'#9e9e9e'},rgba(248,57,41,0));`,
  555. table: 'border-spacing:0;overflow:auto;min-width:100%;margin:10px 0;border-collapse: collapse;',
  556. th: 'background-color: whitesmoke;border: 1px solid #2d2d2d;padding:10rpx;',
  557. td: 'border: 1px solid #2d2d2d;padding:10rpx;',
  558. pre: `
  559. color: #c7254e;
  560. padding: 20rpx;
  561. border-radius: 5px;
  562. white-space: pre;
  563. overflow: auto;
  564. margin:12rpx 0;
  565. font-size:13px;
  566. background: #2d2d2d;
  567. `,
  568. },
  569. };
  570. },
  571. computed: {
  572. ...mapGetters(['appInfo', 'isLogin', 'userInfo', 'homeTemplate', 'userData'])
  573. },
  574. watch: {
  575. appInfo: function(e) {
  576. let that = this;
  577. // uni.setNavigationBarTitle({
  578. // title: that.appInfo.site_name
  579. // });
  580. // console.log(that.appInfo.site_logo_path);
  581. // that.$base64.imageUrlToBase64(that.appInfo.site_logo_path)
  582. }
  583. },
  584. onReady() {
  585. let that = this;
  586. // #ifdef MP-WEIXIN
  587. clearTimeout(timer);
  588. // 在适合的场景显示插屏广告
  589. timer = setTimeout(function() {
  590. // 在页面onLoad回调事件中创建插屏广告实例
  591. if (wx.createInterstitialAd && that.appInfo.interstitial_status == 1) {
  592. interstitialAd = wx.createInterstitialAd({
  593. adUnitId: that.appInfo.interstitial_id
  594. });
  595. interstitialAd.onLoad(() => {});
  596. interstitialAd.onError(err => {});
  597. interstitialAd.onClose(() => {
  598. if (that.appInfo.interstitial_infinite_status && that.appInfo
  599. .interstitial_infinite_status == 1) {
  600. that.showInterstitial();
  601. } else {
  602. interstitialAd.show().catch(err => {
  603. console.error(err);
  604. });
  605. }
  606. });
  607. interstitialAd.show().catch(err => {});
  608. }
  609. }, 4000);
  610. // #endif
  611. },
  612. onLoad() {
  613. var that = this;
  614. if (that.platform == 'wxMiniProgram') {
  615. var menumtop = uni.getMenuButtonBoundingClientRect().top - uni.getSystemInfoSync().statusBarHeight;
  616. var paddingtop = uni.getSystemInfoSync().statusBarHeight + menumtop;
  617. that.tobheight = menumtop + paddingtop + uni.getMenuButtonBoundingClientRect().height;
  618. }
  619. this.posterheight = uni.$u.sys().windowHeight-this.tobheight
  620. if (that.$Route.query.chat4) {
  621. that.showchat4 = true
  622. this.sheetlist[1].color = '#000'
  623. this.sheetlist[0].color = '#26b3a0d6'
  624. if (this.$Route.query.showchat4) {
  625. // console.log(this.$Route.query.showchat4);
  626. // this.send(this.$Route.query.showchat4);
  627. // #ifdef H5
  628. this.h5question = this.$Route.query.showchat4;
  629. // this.eventsource()
  630. this.aigetAddress();
  631. // #endif
  632. }
  633. }
  634. if (this.$Route.query.question) {
  635. if (this.$Route.query.selectornot) {
  636. this.selectornot = this.$Route.query.selectornot
  637. }
  638. // #ifdef MP-WEIXIN
  639. this.send(this.$Route.query.question);
  640. // #endif
  641. // #ifdef H5
  642. this.h5question = this.$Route.query.question;
  643. // this.eventsource()
  644. this.aigetAddress();
  645. // #endif
  646. }
  647. this.spmplatform = ['H5', 'wxOfficialAccount', 'wxMiniProgram', 'App'].indexOf(this.platform) + 1;
  648. this.followornot = true;
  649. // #ifdef H5
  650. this.toaigetAddress();
  651. // #endif
  652. this.isLoading = false
  653. this.initGpt();
  654. this.getCommissionSetting()
  655. this.onmessage();
  656. uni.onSocketError(function(res) {});
  657. // #ifdef MP-WEIXIN
  658. let self = this;
  659. recorderManager.onStop(function(res) {
  660. self.aiaudiocheck(res.tempFilePath)
  661. });
  662. // #endif
  663. this.initHighLight();
  664. },
  665. onShow: function() {
  666. if (this.isLogin) {
  667. this.getUserData();
  668. }
  669. this.getPlan();
  670. this.systemwechat()
  671. },
  672. onUnload() {
  673. this.followornot = false;
  674. clearInterval(time2);
  675. clearTimeout(timingr);
  676. uni.$emit('stop')
  677. if (this.$ws.socketStatus()) {
  678. this.$ws.completeClose();
  679. }
  680. },
  681. onHide() {
  682. if (this.$ws.socketStatus()) {
  683. this.$ws.completeClose();
  684. }
  685. },
  686. onReachBottom() {},
  687. methods: {
  688. ...mapActions(['getUserInfo', 'showAuthModal', 'getUserData']),
  689. systemwechat(){
  690. this.$http('conf.getGroupConf', { group: 'system.wechat' }).then(res => {
  691. if (res.code == 0) {
  692. this.gzhqrcode = res.data.qrcode_path
  693. const focuson = uni.getStorageSync('focuson');
  694. // console.log(focuson);
  695. if(!focuson){
  696. if(this.gzhqrcode){
  697. if(this.isLogin&&this.appInfo.is_show_logged_qrcode == 1 ){
  698. this.showconcern = true
  699. }
  700. }
  701. }
  702. }
  703. })
  704. },
  705. initHighLight() {
  706. hljs.configure({
  707. useBR: true,
  708. tabReplace: " ",
  709. });
  710. marked.setOptions({
  711. renderer: new marked.Renderer(),
  712. gfm: true,
  713. tables: true,
  714. breaks: false,
  715. pedantic: false,
  716. highlight: function(code, lang) {
  717. if (lang && hljs.getLanguage(lang)) {
  718. return hljs.highlight(lang, code, true).value;
  719. } else {
  720. return hljs.highlightAuto(code).value;
  721. }
  722. },
  723. });
  724. },
  725. concernclose(){
  726. this.showconcern = false
  727. },
  728. // 角色角色初始化
  729. switcmode() {
  730. // #ifdef MP-WEIXIN
  731. this.zhuangtai = this.appInfo.site_name ? this.appInfo.site_name :
  732. 'AI问答机器人';
  733. // #endif
  734. // #ifdef H5
  735. uni.setNavigationBarTitle({
  736. title: this.appInfo.site_name ? this.appInfo.site_name : 'AI问答机器人'
  737. });
  738. this.zhuangtai = this.homeTemplate.mode && this.homeTemplate.mode.length >
  739. 0 ? this.homeTemplate.mode[this
  740. .selectornot].name : 'AI问答机器人';
  741. // #endif
  742. this.Audio()
  743. this.$nextTick(() => {
  744. // 清空内容框中的内容
  745. this.content = '';
  746. uni.pageScrollTo({
  747. scrollTop: 99999,
  748. duration: 300
  749. });
  750. });
  751. },
  752. //选择模型
  753. selectClick(index) {
  754. for (var a = 0; a < this.sheetlist.length; a++) {
  755. this.sheetlist[a].color = '#000'
  756. }
  757. // #ifdef H5
  758. this.sheetlist[index.index].color = '#26b3a0d6'
  759. // #endif
  760. // #ifdef MP-WEIXIN
  761. this.sheetlist[index.index - 1].color = '#26b3a0d6'
  762. // #endif
  763. if (index.index == 0) {
  764. this.showchat4 = true
  765. } else {
  766. this.showchat4 = false
  767. }
  768. this.switcmode()
  769. this.getcurrentmodel()
  770. },
  771. //开始录音的方法
  772. uploadRecord() {
  773. // 开始录音
  774. if (!this.rec) {
  775. uni.showToast({
  776. title: '未打开录音权限'
  777. })
  778. return;
  779. }
  780. this.rec.start();
  781. this.showlongpress = true
  782. },
  783. //结束录音的方法
  784. h5btn_sub_stop() {
  785. var This = this;
  786. var rec = This.rec;
  787. This.rec = null;
  788. if (!rec) {
  789. uni.showToast({
  790. title: '未打开录音'
  791. })
  792. return;
  793. }
  794. rec.stop(function(blob, duration) {
  795. var reader = new FileReader();
  796. reader.addEventListener("load", function() {
  797. if (reader.result.length > 100) {
  798. This.he_show = true
  799. }
  800. }, false);
  801. reader.readAsDataURL(blob);
  802. // console.log(blob,duration,'blob')
  803. let blobURL = window.URL.createObjectURL(blob)
  804. // console.log(blobURL, '--------')
  805. This.aiaudiocheck(blobURL)
  806. }, function(s) {
  807. This.showlongpress = false
  808. }, true); //自动close
  809. },
  810. //登录
  811. getroute() {
  812. if (!this.isLogin) {
  813. uni.setStorageSync('route', '/pages/chat/chat');
  814. }
  815. this.Audio()
  816. },
  817. //关闭语音输出
  818. Audio() {
  819. uni.$emit('stop')
  820. },
  821. //语音识别
  822. aiaudiocheck(e) {
  823. var that = this;
  824. // console.log(e, '5');
  825. uni.showLoading({
  826. title: '识别中'
  827. })
  828. uni.uploadFile({
  829. url: apiurl('ai/recognizer'),
  830. filePath: e,
  831. name: 'speech',
  832. header: {
  833. platform: that.platform
  834. },
  835. success: res2 => {
  836. uni.hideLoading();
  837. let a = JSON.parse(res2.data);
  838. if (a.code == 0) {
  839. uni.showToast({
  840. title: '识别成功',
  841. })
  842. this.content += a.data.result[0]
  843. this.thecontent += a.data.result[0]
  844. } else {
  845. uni.showToast({
  846. title: '识别失败',
  847. icon: 'none'
  848. })
  849. }
  850. }
  851. });
  852. },
  853. //语音输入
  854. openmicrophone() {
  855. var that = this;
  856. this.Audio()
  857. this.cancel = true
  858. if (!this.isLogin) {
  859. uni.navigateTo({
  860. url: '/pages/user/signin'
  861. });
  862. uni.setStorageSync('route', '/pages/chat/chat');
  863. return;
  864. }
  865. // #ifdef H5
  866. let This = this;
  867. let rec = This.rec = Recorder({
  868. type: "wav", // wav格式, 需要使用的type类型,需提前把格式支持文件加载进来
  869. bitRate: 16, // 比特率kbps,越大音质越好
  870. sampleRate: 16000, // 采样率hz,每秒音波震动次数,越大细节越丰富
  871. onProcess: function(buffers, powerLevel, duration, sampleRate) {
  872. if (duration > 60000) {
  873. This.h5btn_sub_stop()
  874. This.showlongpress = false
  875. This.soundrecording = false
  876. }
  877. } //录音实时回调,大约1秒调用12次回调
  878. });
  879. rec.open(function() {
  880. // console.log('打开成功:');
  881. // 渲染音频波形图
  882. This.soundrecording = true
  883. }, function(msg, isUserNotAllow) {
  884. uni.showToast({
  885. title: '麦克风已拒绝打开',
  886. icon: 'none'
  887. })
  888. // 浏览器不支持录音、用户拒绝麦克风权限、或者非安全环境(非https、file等
  889. // console.log((isUserNotAllow ? "UserNotAllow," : "") + "无法录音:" + msg);
  890. });
  891. // #endif
  892. // #ifdef MP-WEIXIN
  893. uni.getSetting({
  894. success: (res) => {
  895. if (res.authSetting['scope.record'] == false) {
  896. uni.showModal({
  897. confirmText: '去打开',
  898. content: '请先开启麦克风授权',
  899. title: '提示',
  900. confirmColor: '#26B3A0',
  901. success(res) {
  902. // console.log(res);
  903. if (res.confirm) {
  904. uni.openSetting({
  905. success: function(ress) {
  906. // console.log(ress);
  907. }
  908. });
  909. }
  910. }
  911. })
  912. return false
  913. } else {
  914. uni.authorize({
  915. scope: 'scope.record',
  916. success: (res) => {
  917. that.soundrecording = true
  918. },
  919. fail: (res) => {
  920. uni.showToast({
  921. title: '麦克风打开失败',
  922. icon: 'none'
  923. })
  924. }
  925. })
  926. }
  927. },
  928. })
  929. // #endif
  930. },
  931. startrecording() {
  932. // console.log('开始录音');
  933. // #ifdef H5
  934. // this.$refs.recorder.start()
  935. this.uploadRecord()
  936. // #endif
  937. // #ifdef MP-WEIXIN
  938. recorderManager.start({
  939. sampleRate: 16000,
  940. numberOfChannels: 1,
  941. format: 'aac',
  942. duration: 60000
  943. })
  944. this.showlongpress = true
  945. // #endif
  946. },
  947. stoprecording() {
  948. // console.log('停止录音');
  949. // #ifdef H5
  950. // this.$refs.recorder.stop()
  951. this.h5btn_sub_stop()
  952. // #endif
  953. // #ifdef MP-WEIXIN
  954. recorderManager.stop();
  955. // #endif
  956. this.showlongpress = false
  957. this.soundrecording = false
  958. },
  959. //语音输出
  960. aittsjob(res) {
  961. this.talkList[res.index].audiolink = res.speech_url
  962. },
  963. //ai绘画信息
  964. initGpt() {
  965. // console.log(this.homeTemplate.mode);
  966. // #ifdef MP-WEIXIN
  967. this.zhuangtai = this.appInfo.site_name ? this.appInfo
  968. .site_name :
  969. 'AI问答机器人';
  970. // #endif
  971. // #ifdef H5
  972. uni.setNavigationBarTitle({
  973. title: this.appInfo.site_name ? this.appInfo.site_name : 'AI问答机器人'
  974. });
  975. this.zhuangtai = this.homeTemplate.mode && this.homeTemplate.mode.length >
  976. 0 ? this
  977. .homeTemplate.mode[this
  978. .selectornot].name : 'AI问答机器人';
  979. // #endif
  980. this.commonqrcodePath();
  981. //
  982. // this.onmessage();
  983. },
  984. // 关闭跟随
  985. touchmove() {
  986. this.followornot = false;
  987. },
  988. // 是否显示分销按钮
  989. getCommissionSetting() {
  990. this.$http('conf.getGroupConf', {
  991. group: 'system.commission'
  992. }).then(res => {
  993. if (res.code == 0) {
  994. this.is_commission = res.data.is_commission
  995. }
  996. });
  997. },
  998. // 上下文倒计时
  999. getcontext() {
  1000. var that = this;
  1001. that.timing--;
  1002. // console.log(that.timing);
  1003. if (that.timing == 0) {
  1004. // console.log('关闭上下文定时器');
  1005. clearTimeout(timingr);
  1006. that.timing = that.appInfo.text_expire_time ? Number(that.appInfo.text_expire_time) :
  1007. 30;
  1008. // console.log('取消下文关联');
  1009. that.showcontext = false
  1010. return;
  1011. }
  1012. timingr = setTimeout(() => {
  1013. that.getcontext();
  1014. }, 1000);
  1015. },
  1016. // 监听WebSocket是否打开
  1017. waitWss() {
  1018. return new Promise((resolve, reject) => {
  1019. uni.onSocketOpen(function(res) {
  1020. // console.log('WebSocket连接已打开!');
  1021. resolve(1);
  1022. });
  1023. });
  1024. },
  1025. // 监听WebSocket是否关闭
  1026. waitClose() {
  1027. return new Promise((resolve, reject) => {
  1028. uni.onSocketClose(function(res) {
  1029. // console.log('WebSocket 已关闭!');
  1030. resolve(1);
  1031. });
  1032. });
  1033. },
  1034. // fetch模式url
  1035. aigetAddress() {
  1036. var that = this;
  1037. let uniacid = uni.getStorageSync("uniacid") || "";
  1038. that.chatgpturl = API_STEROOT + 'api.ai/chatgpt?uniacid=' + uniacid;
  1039. that.send(that.h5question);
  1040. },
  1041. // fetch模式url
  1042. toaigetAddress() {
  1043. var that = this;
  1044. let uniacid = uni.getStorageSync("uniacid") || "";
  1045. that.chatgpturl = API_STEROOT + 'api.ai/chatgpt?uniacid=' + uniacid;
  1046. },
  1047. // 海报二维码
  1048. commonqrcodePath() {
  1049. let spm = this.userInfo.id + '.1.0.' + this.spmplatform + '.1';
  1050. this.$http('common.qrcodePath', {
  1051. spm: spm
  1052. }).then(res => {
  1053. if (res.code == 0) {
  1054. this.qrcode = res.data;
  1055. }
  1056. });
  1057. },
  1058. //长按复制
  1059. copy(e) {
  1060. var that = this;
  1061. var text = e.currentTarget.dataset.text;
  1062. uni.setClipboardData({
  1063. data: text,
  1064. success(res) {
  1065. uni.getClipboardData({
  1066. success(res) {}
  1067. });
  1068. }
  1069. });
  1070. },
  1071. //输入框聚焦操作
  1072. focusinput() {
  1073. this.showexpand = false;
  1074. this.$nextTick(() => {
  1075. uni.pageScrollTo({
  1076. scrollTop: 99999,
  1077. duration: 300
  1078. });
  1079. });
  1080. if (!this.isLogin) {
  1081. uni.navigateTo({
  1082. url: '/pages/user/signin'
  1083. });
  1084. uni.setStorageSync('route', '/pages/chat/chat');
  1085. return;
  1086. }
  1087. },
  1088. signSign() {
  1089. uni.navigateTo({
  1090. url: '/pages/user/member/member'
  1091. });
  1092. this.signShow = false
  1093. },
  1094. //功能按钮显示
  1095. blurinput() {
  1096. this.showexpand = true;
  1097. },
  1098. //角色角色
  1099. commontemplate() {
  1100. this.$store.dispatch('getTemplate');
  1101. },
  1102. //敏感词过滤检测
  1103. getcheckText() {
  1104. var that = this;
  1105. return new Promise((resolve, reject) => {
  1106. that.$http('ai.checkText', {
  1107. prompt: that.thecontent
  1108. }).then(res => {
  1109. if (res.code == 0) {
  1110. resolve(1);
  1111. } else {
  1112. let data = {
  1113. id: new Date().getTime(),
  1114. content: '该问题已被隐藏!',
  1115. type: 1,
  1116. toid: that.toid,
  1117. fromid: that.userInfo.id,
  1118. avatar: that.userInfo.avatar,
  1119. nickname: that.userInfo.nickname,
  1120. done: true
  1121. };
  1122. that.talkList.push(data);
  1123. let chat_data = {
  1124. id: new Date().getTime(),
  1125. content: res.msg,
  1126. type: 1,
  1127. toid: this.toid,
  1128. fromid: -1,
  1129. avatar: this.homeTemplate.mode && this.homeTemplate.mode.length > 0 &&
  1130. this.homeTemplate.mode[this.selectornot].img_file != null && this
  1131. .homeTemplate.mode[this.selectornot].img_file.path,
  1132. nickname: this.homeTemplate.mode && this.homeTemplate.mode.length >
  1133. 0 && this.homeTemplate.mode[this.selectornot].name,
  1134. show_flash: false,
  1135. done: true,
  1136. donec: true
  1137. };
  1138. this.talkList.push(chat_data);
  1139. this.$nextTick(() => {
  1140. // 清空内容框中的内容
  1141. this.content = '';
  1142. uni.pageScrollTo({
  1143. scrollTop: 99999,
  1144. duration: 300
  1145. });
  1146. });
  1147. }
  1148. })
  1149. });
  1150. },
  1151. getPlan() {
  1152. let that = this;
  1153. this.$http('conf.getGroupConf', {
  1154. group: 'system.plan'
  1155. }).then(res => {
  1156. if (res.code == 0) {
  1157. this.plan = res.data
  1158. let gpt = this.appInfo;
  1159. // #ifdef H5
  1160. // this.sheetlist[0].disabled = gpt.is_gpt4 == 1 ? false : true
  1161. // this.sheetlist[0].name = gpt.gpt4_alias ? gpt.gpt4_alias : 'ChatGPT 4.0'
  1162. // this.sheetlist[0].subname = gpt.gpt4_intro ? gpt.gpt4_intro : '高效沟通·简单提问'
  1163. // this.sheetlist[1].name = gpt.gpt35_alias ? gpt.gpt35_alias : 'ChatGPT 3.5'
  1164. // this.sheetlist[1].subname = gpt.gpt35_intro ? gpt.gpt35_intro : '高效沟通·简单提问'
  1165. if(gpt.is_gpt4 == 2){
  1166. this.sheetlist.shift()
  1167. this.sheetlist[0].name = gpt.gpt35_alias?gpt.gpt35_alias:'ChatGPT 3.5'
  1168. this.sheetlist[0].subname = gpt.gpt35_intro?gpt.gpt35_intro:'高效沟通·简单提问'
  1169. }else{
  1170. this.sheetlist[0].name = gpt.gpt4_alias?gpt.gpt4_alias:'ChatGPT 4.0'
  1171. this.sheetlist[0].subname = gpt.gpt4_intro?gpt.gpt4_intro:'高效沟通·简单提问'
  1172. this.sheetlist[1].name = gpt.gpt35_alias?gpt.gpt35_alias:'ChatGPT 3.5'
  1173. this.sheetlist[1].subname = gpt.gpt35_intro?gpt.gpt35_intro:'高效沟通·简单提问'
  1174. }
  1175. // #endif
  1176. // #ifdef MP-WEIXIN
  1177. this.sheetlist[0].name = gpt.gpt35_alias ? gpt.gpt35_alias : 'ChatGPT 3.5'
  1178. this.sheetlist[0].subname = gpt.gpt35_intro ? gpt.gpt35_intro : '高效沟通·简单提问'
  1179. // #endif
  1180. this.getcurrentmodel()
  1181. }
  1182. })
  1183. },
  1184. getcurrentmodel() {
  1185. let gpt = this.appInfo;
  1186. if (this.showchat4) {
  1187. this.currentmodel = gpt.gpt4_alias ? gpt.gpt4_alias : 'ChatGPT 4.0'
  1188. }else {
  1189. this.currentmodel = gpt.gpt35_alias ? gpt.gpt35_alias : 'ChatGPT 3.5'
  1190. }
  1191. },
  1192. // 发送信息
  1193. async send(e) {
  1194. let that = this;
  1195. if (!that.isLogin) {
  1196. uni.navigateTo({
  1197. url: '/pages/user/signin'
  1198. });
  1199. uni.setStorageSync('route', '/pages/chat/chat');
  1200. return;
  1201. }
  1202. if (that.appInfo.time_member && that.appInfo.time_member == 1) {
  1203. if (that.showchat4) {
  1204. if (that.userData.vip_info && that.userData.is_validity > 0 && that.userData.vip_info.gpt4_used ==
  1205. that.userData.vip_info.gpt4_times && that.userData.coin < that.plan.lock_gpt4) {
  1206. var alias = that.appInfo.number_alias ? that.appInfo.number_alias : '点数';
  1207. // this.signTitle = "<p style='font-weight: 550;font-size: 16px;'>您的提问<span>" + alias +
  1208. // "</span>不足或会员套餐内剩余次数不足,无法发起提问</p>"
  1209. this.signTitle =
  1210. "<p style='font-weight: 550;font-size: 16px;'>提问需要<span style='color: #26b3a0;padding: 0 4px;'>" +
  1211. that.plan.lock_gpt4 + "</span><span>" + alias +
  1212. "</span></p><p style='padding-top: 10px;'>您的提问<span>" + alias +"</span>不足或会员套餐内剩余次数不足,无法发起提问</p>"
  1213. this.signShow = true
  1214. return;
  1215. }
  1216. if (that.userData.is_validity == 0&&that.userData.coin < that.plan.lock_gpt4) {
  1217. var alias = that.appInfo.number_alias ? that.appInfo.number_alias : '点数';
  1218. this.signTitle =
  1219. "<p style='font-weight: 550;font-size: 16px;'>提问需要<span style='color: #26b3a0;padding: 0 4px;'>" +
  1220. that.plan.lock_gpt4 + "</span><span>" + alias +
  1221. "</span></p><p style='padding-top: 10px;'>您的提问<span>" + alias +"</span>不足或会员套餐内剩余次数不足,无法发起提问</p>"
  1222. this.signShow = true
  1223. return;
  1224. }
  1225. } else {
  1226. if (that.userData.is_validity > 0 && that.userData.vip_info.gpt35_used == that.userData.vip_info
  1227. .gpt35_times && that.userData.coin <= 0) {
  1228. var alias = that.appInfo.number_alias ? that.appInfo.number_alias : '点数';
  1229. this.signTitle =
  1230. "<p style='font-weight: 550;font-size: 16px;'>提问需要<span style='color: #26b3a0;padding: 0 4px;'>" +
  1231. 1 + "</span><span>" + alias +
  1232. "</span></p><p style='padding-top: 10px;'>您的提问<span>" + alias +"</span>不足或会员套餐内剩余次数不足,无法发起提问</p>"
  1233. this.signShow = true
  1234. return;
  1235. }
  1236. if (that.userData.is_validity == 0&&that.userData.coin <= 0) {
  1237. var alias = that.appInfo.number_alias ? that.appInfo.number_alias : '点数';
  1238. this.signTitle =
  1239. "<p style='font-weight: 550;font-size: 16px;'>提问需要<span style='color: #26b3a0;padding: 0 4px;'>" +
  1240. 1 + "</span><span>" + alias +
  1241. "</span></p><p style='padding-top: 10px;'>您的提问<span>" + alias +"</span>不足或会员套餐内剩余次数不足,无法发起提问</p>"
  1242. this.signShow = true
  1243. return;
  1244. }
  1245. }
  1246. } else {
  1247. if (that.showchat4 && that.userData.coin < that.plan.lock_gpt4) {
  1248. var alias = that.appInfo.number_alias ? that.appInfo.number_alias : '点数';
  1249. this.signTitle =
  1250. "<p style='font-weight: 550;font-size: 16px;'>提问需要<span style='color: #26b3a0;padding: 0 4px;'>" +
  1251. that.plan.lock_gpt4 + "</span><span>" + alias +
  1252. "</span></p><p style='padding-top: 10px;'>您当前有<span style='color: #26b3a0;padding: 0 4px;'>" +
  1253. that.userData.coin + "</span><span>" + alias + "</span>,无法发起提问,快去获取<span>" + alias +
  1254. "</span>吧</p>"
  1255. this.signShow = true
  1256. return;
  1257. }
  1258. if (!that.showchat4 && that.userData.coin <= 0) {
  1259. var alias = that.appInfo.number_alias ? that.appInfo.number_alias : '点数';
  1260. this.signTitle =
  1261. "<p style='font-weight: 550;font-size: 16px;'>提问需要<span style='color: #26b3a0;padding: 0 4px;'>" +
  1262. 1 + "</span><span>" + alias +
  1263. "</span></p><p style='padding-top: 10px;'>您当前有<span style='color: #26b3a0;padding: 0 4px;'>" +
  1264. that.userData.coin + "</span><span>" + alias + "</span>,无法发起提问,快去获取<span>" + alias +
  1265. "</span>吧</p>"
  1266. this.signShow = true
  1267. return;
  1268. }
  1269. }
  1270. // if (that.showchat4) {
  1271. // if (that.userData.coin < that.plan.lock_gpt4) {
  1272. // var alias = that.appInfo.number_alias ? that.appInfo.number_alias : '点数';
  1273. // this.signTitle =
  1274. // "<p style='font-weight: 550;font-size: 16px;'>提问需要<span style='color: #26b3a0;padding: 0 4px;'>" +
  1275. // that.plan.lock_gpt4 + "</span><span>" + alias +
  1276. // "</span></p><p style='padding-top: 10px;'>您当前有<span style='color: #26b3a0;padding: 0 4px;'>" +
  1277. // that.userData.coin + "</span><span>" + alias + "</span>,此模型不支持会员套餐,无法发起提问,快去获取<span>" + alias +
  1278. // "</span>吧</p>"
  1279. // this.signShow = true
  1280. // return;
  1281. // }
  1282. // }
  1283. // if (that.appInfo.time_member && that.appInfo.time_member == 1) {
  1284. // if (that.userData.is_validity > 0 && that.userData.vip_info.gpt35_used == that.userData.vip_info.gpt35_times && that.userData.coin <= 0) {
  1285. // var alias = that.appInfo.number_alias ? that.appInfo.number_alias : '点数';
  1286. // this.signTitle = "<p style='font-weight: 550;font-size: 16px;'>您的提问<span>"+alias+"</span>/会员套餐内剩余次数不足</p>"
  1287. // this.signShow = true
  1288. // return;
  1289. // }
  1290. // if (that.userData.is_validity == 0) {
  1291. // if (that.userData.coin <= 0) {
  1292. // var alias = that.appInfo.number_alias ? that.appInfo.number_alias : '点数';
  1293. // this.signTitle = "<p style='font-weight: 550;font-size: 16px;'>您的提问<span>" + alias +
  1294. // "</span>/会员套餐不足</p>"
  1295. // this.signShow = true
  1296. // return;
  1297. // }
  1298. // }
  1299. // } else {
  1300. // if (that.userData.coin <= 0) {
  1301. // var alias = that.appInfo.number_alias ? that.appInfo.number_alias : '点数';
  1302. // this.signTitle = "<p style='font-weight: 550;font-size: 16px;'>您的提问<span>" + alias +
  1303. // "</span>/会员套餐不足</p>"
  1304. // this.signShow = true
  1305. // return;
  1306. // }
  1307. // }
  1308. if (that.talkList.length > 1 && !that.talkList[that.talkList.length - 1].done) {
  1309. uni.showToast({
  1310. title: '正在输入回答,请等待输入完成',
  1311. icon: 'none'
  1312. });
  1313. return;
  1314. }
  1315. if (!e) {
  1316. uni.showToast({
  1317. title: '请输入有效的内容',
  1318. icon: 'none'
  1319. });
  1320. return;
  1321. }
  1322. that.thecontent = e;
  1323. // console.log('提问内容检测');
  1324. uni.showLoading({})
  1325. // #ifdef H5
  1326. let check = this.appInfo.is_h5_filter && this.appInfo.is_h5_filter == 1 ? await this.getcheckText() :
  1327. 1;
  1328. // #endif
  1329. // #ifdef MP-WEIXIN
  1330. let check = await this.getcheckText();
  1331. // #endif
  1332. if (check == 1) {
  1333. uni.hideLoading();
  1334. // 将当前发送信息 添加到消息列表。
  1335. let data = {
  1336. id: new Date().getTime(),
  1337. content: e,
  1338. type: 1,
  1339. toid: this.toid,
  1340. fromid: this.userInfo.id,
  1341. avatar: this.userInfo.avatar,
  1342. nickname: this.userInfo.nickname,
  1343. done: true
  1344. };
  1345. this.talkList.push(data);
  1346. // console.log(this.homeTemplate.mode[this.selectornot]);
  1347. // #ifdef MP-WEIXIN
  1348. if (this.showchat4) {
  1349. let chat_data = {
  1350. id: new Date().getTime(),
  1351. content: '正在输入中,请等待...',
  1352. type: 2,
  1353. toid: this.toid,
  1354. fromid: -1,
  1355. avatar: this.homeTemplate.mode && this.homeTemplate.mode[this.selectornot].img_file !=
  1356. null && this.homeTemplate.mode[this.selectornot].img_file.path ? this.homeTemplate
  1357. .mode[this.selectornot].img_file.path : '/static/images/head.jpg',
  1358. nickname: this.homeTemplate.mode && this.homeTemplate.mode[this.selectornot].name ?
  1359. this.homeTemplate.mode[this.selectornot].name : 'AI问答机器人',
  1360. };
  1361. this.talkList.push(chat_data);
  1362. } else {
  1363. let chat_data = {
  1364. id: new Date().getTime(),
  1365. content: '正在思考中...',
  1366. type: 1,
  1367. toid: this.toid,
  1368. fromid: -1,
  1369. avatar: this.homeTemplate.mode && this.homeTemplate.mode[this.selectornot].img_file !=
  1370. null && this.homeTemplate.mode[this.selectornot].img_file.path ? this.homeTemplate
  1371. .mode[this.selectornot].img_file.path : '/static/images/open.png',
  1372. nickname: this.homeTemplate.mode && this.homeTemplate.mode[this.selectornot].name ?
  1373. this.homeTemplate.mode[this.selectornot].name : 'AI问答机器人',
  1374. show_flash: true,
  1375. done: false
  1376. };
  1377. this.talkList.push(chat_data);
  1378. }
  1379. // #endif
  1380. // #ifdef H5
  1381. let chat_data = {
  1382. id: new Date().getTime(),
  1383. content: '正在思考中...',
  1384. type: 1,
  1385. toid: this.toid,
  1386. fromid: -1,
  1387. avatar: this.homeTemplate.mode && this.homeTemplate.mode[this.selectornot].img_file !=
  1388. null && this.homeTemplate.mode[this.selectornot].img_file.path ? this.homeTemplate
  1389. .mode[this.selectornot].img_file.path : '/static/images/open.png',
  1390. nickname: this.homeTemplate.mode && this.homeTemplate.mode[this.selectornot].name ? this
  1391. .homeTemplate.mode[this.selectornot].name : 'AI问答机器人',
  1392. show_flash: true,
  1393. done: false
  1394. };
  1395. this.talkList.push(chat_data);
  1396. // #endif
  1397. // console.log(this.talkList);
  1398. this.$nextTick(() => {
  1399. // 清空内容框中的内容
  1400. this.content = '';
  1401. uni.pageScrollTo({
  1402. scrollTop: 999999,
  1403. duration: 300
  1404. });
  1405. });
  1406. // 重置是否来数据的判断
  1407. this.showanswer = false;
  1408. // 允许跟随到最底部
  1409. this.followornot = true;
  1410. // 关闭重置上下文的秒倒计时
  1411. // clearTimeout(timingr);
  1412. // this.timing = this.appInfo.text_expire_time ? Number(this.appInfo.text_expire_time) : 30;
  1413. // #ifdef MP-WEIXIN
  1414. // 判断是否连接wss
  1415. if (!this.$ws.socketStatus()) {
  1416. // 重置倒计时15秒后的wss未返数据走直连模式
  1417. this.showdirect = true;
  1418. // console.log('15秒倒计时开始');
  1419. this.countdown();
  1420. // console.log('重连wss');
  1421. this.$ws.init();
  1422. let re = await this.waitWss();
  1423. if (re == 1) {
  1424. // console.log('等待wss打开后执行');
  1425. this.getChatGPT(e);
  1426. }
  1427. } else {
  1428. // 关闭wss
  1429. that.$ws.completeClose();
  1430. // console.log('15秒倒计时开始');
  1431. this.countdown();
  1432. let answer = '';
  1433. if (that.talkList.length > 2) {
  1434. // answer = that.talkList[that.talkList.length - 4].content + '\n' + that
  1435. // .talkList[that
  1436. // .talkList.length - 3].content;
  1437. answer = that.talkList[that.talkList.length - 3].content;
  1438. }
  1439. // console.log('倒计时15秒后不再走直连模式');
  1440. this.showdirect = false;
  1441. this.directGpt(that.thecontent, answer);
  1442. }
  1443. // #endif
  1444. // #ifdef H5
  1445. this.showdirect = true;
  1446. // console.log('15秒倒计时开始');
  1447. this.countdown();
  1448. // console.log('走方案2');
  1449. that.fetchmodel(that.thecontent);
  1450. // #endif
  1451. }
  1452. },
  1453. //定时器
  1454. countdown() {
  1455. var that = this;
  1456. that.second--;
  1457. if (that.second == 0) {
  1458. if (!that.showanswer) {
  1459. let answer = '';
  1460. if (that.talkList.length > 2) {
  1461. answer = that.talkList[that.talkList.length - 3].content;
  1462. }
  1463. uni.showLoading({
  1464. title: '加载中...'
  1465. });
  1466. // clearTimeout(down);
  1467. // console.log('关闭定时器');
  1468. // #ifdef MP-WEIXIN
  1469. if (that.$ws.socketStatus()) {
  1470. // console.log('关闭直连');
  1471. that.$ws.completeClose();
  1472. }
  1473. // #endif
  1474. if (that.showdirect) {
  1475. setTimeout(() => {
  1476. uni.hideLoading();
  1477. that.second = 11;
  1478. that.directGpt(that.thecontent, answer);
  1479. }, 1500);
  1480. } else {
  1481. uni.hideLoading();
  1482. that.second = 11;
  1483. if (that.talkList[that.question_index].content == '正在思考中...') {
  1484. that.talkList[that.question_index].content = '请等我几秒钟,正在输入回答...';
  1485. }
  1486. }
  1487. return;
  1488. } else {
  1489. that.second = 11;
  1490. clearTimeout(down);
  1491. // console.log('关闭定时器');
  1492. }
  1493. // clearTimeout(down);
  1494. return;
  1495. }
  1496. down = setTimeout(() => {
  1497. // console.log(that.showanswer);
  1498. if (that.showanswer) {
  1499. clearTimeout(down);
  1500. // console.log('关闭定时器');
  1501. that.second = 11;
  1502. return;
  1503. }
  1504. that.countdown();
  1505. }, 1000);
  1506. // console.log(second);
  1507. },
  1508. //wss返回数据
  1509. onmessage() {
  1510. let that = this,
  1511. message = '';
  1512. uni.onSocketMessage(function(res) {
  1513. that.showanswer = true;
  1514. let a = res.data;
  1515. if (a.indexOf('wike_err:') != -1) {
  1516. uni.showToast({
  1517. title: '报错:' + a,
  1518. icon: 'none'
  1519. });
  1520. that.talkList[that.question_index].show_flash = false;
  1521. that.talkList[that.question_index].content = '报错:' + a;
  1522. that.talkList[that.question_index].done = true;
  1523. return;
  1524. }
  1525. if (!that.$ws.socketStatus()) {
  1526. uni.showToast({
  1527. title: '连接错误',
  1528. icon: 'none'
  1529. });
  1530. that.talkList[that.question_index].show_flash = false;
  1531. that.talkList[that.question_index].content = '报错';
  1532. return;
  1533. }
  1534. if (a.indexOf('[DONE]') != -1) {
  1535. that.$nextTick(() => {
  1536. // that.timing = that.appInfo.text_expire_time ? Number(that.appInfo
  1537. // .text_expire_time) : 30;
  1538. // that.showcontext = true;
  1539. // that.getcontext()
  1540. that.talkList[that.question_index].show_flash = false;
  1541. that.talkList[that.question_index].done = true;
  1542. that.record(that.talkList[that.answer_index].content, message);
  1543. message = '';
  1544. if (that.$ws.socketStatus()) {
  1545. that.$ws.completeClose();
  1546. }
  1547. that.$nextTick(() => {
  1548. if (that.followornot) {
  1549. uni.pageScrollTo({
  1550. scrollTop: 99999,
  1551. duration: 300
  1552. });
  1553. }
  1554. });
  1555. });
  1556. } else {
  1557. var b = a.split('data:').filter(w => !!w.trim() && w.trim() !== '[DONE]');
  1558. var c = '';
  1559. b.map(w => JSON.parse(w))
  1560. .map(w => (c = w.choices[0].delta.content))
  1561. .join('');
  1562. if (that.followornot) {
  1563. uni.pageScrollTo({
  1564. scrollTop: 99999,
  1565. duration: 0
  1566. });
  1567. }
  1568. if (c != undefined) {
  1569. message += c;
  1570. }
  1571. if (that.thoroughfare == 1) {
  1572. that.talkList[that.question_index].backups = message;
  1573. that.talkList[that.question_index].content = marked(message);
  1574. }
  1575. }
  1576. });
  1577. },
  1578. //wss模式
  1579. getChatGPT(e) {
  1580. var that = this;
  1581. let i = 1,
  1582. message = '';
  1583. this.question_index = that.talkList.length - 1;
  1584. this.answer_index = that.talkList.length - 2;
  1585. let answer = '';
  1586. if (that.talkList.length > 2 ) {
  1587. answer = that.talkList[that.question_index - 2].content;
  1588. }
  1589. var ty = {
  1590. prompt: e,
  1591. guide: that.homeTemplate.mode[that.selectornot].guide,
  1592. answer: answer,
  1593. key: that.appInfo.sk ? that.appInfo.sk : '',
  1594. lines: that.appInfo.connect_lines ? this.appInfo.connect_lines : 1,
  1595. temperature: that.appInfo.temperature ? this.appInfo.temperature : 0,
  1596. presence_penalty: that.appInfo.presence_penalty ? this.appInfo.presence_penalty : 0,
  1597. frequency_penalty: that.appInfo.frequency_penalty ? this.appInfo.frequency_penalty : 0,
  1598. };
  1599. var json = JSON.stringify(ty);
  1600. that.thoroughfare = 1
  1601. that.$ws.send(json);
  1602. },
  1603. //php模式
  1604. directGpt(e, answer) {
  1605. // console.log('走方案3');
  1606. let that = this;
  1607. this.question_index = that.talkList.length - 1;
  1608. if (this.showdirect) {
  1609. that.talkList[that.question_index].content = '请等我几秒钟,正在输入回答...';
  1610. }
  1611. // this.showdirect = false;
  1612. that.showanswer = this.showdirect;
  1613. that.thoroughfare = 3
  1614. // var url =
  1615. that.$http(that.showchat4 ? 'ai.chat4' : 'ai.chat', {
  1616. prompt: e,
  1617. guide: that.homeTemplate.mode[that.selectornot].guide,
  1618. answer: answer
  1619. }).then(res => {
  1620. if (that.thoroughfare == 3) {
  1621. if (res.code == 0) {
  1622. that.talkList[that.question_index].backups = res.data.trim();
  1623. that.talkList[that.question_index].content = marked(res.data.trim());
  1624. that.talkList[that.question_index].show_flash = false;
  1625. that.talkList[that.question_index].done = true;
  1626. that.talkList[that.question_index].type = 1;
  1627. } else if (res.code == 3 || res.code == 1) {
  1628. that.talkList[that.question_index].content = res.msg;
  1629. that.talkList[that.question_index].show_flash = false;
  1630. that.talkList[that.question_index].done = true;
  1631. that.talkList[that.question_index].type = 1;
  1632. } else {
  1633. that.talkList[that.question_index].content = res.msg;
  1634. that.talkList[that.question_index - 1].content = '该问题已被隐藏!';
  1635. that.talkList[that.question_index].show_flash = false;
  1636. that.talkList[that.question_index].done = true;
  1637. that.talkList[that.question_index].type = 1;
  1638. }
  1639. that.showanswer = true;
  1640. that.getUserData();
  1641. // that.timing = that.appInfo.text_expire_time ? Number(that.appInfo
  1642. // .text_expire_time) : 30;
  1643. // that.getcontext();
  1644. that.$nextTick(() => {
  1645. // 清空内容框中的内容
  1646. that.content = '';
  1647. if (that.followornot) {
  1648. uni.pageScrollTo({
  1649. scrollTop: 99999,
  1650. duration: 300
  1651. });
  1652. }
  1653. });
  1654. }
  1655. });
  1656. },
  1657. //fetch模式
  1658. fetchmodel(e) {
  1659. // console.log('走方案2');
  1660. var that = this;
  1661. let i = 1,
  1662. message = '';
  1663. let answer = '';
  1664. that.thoroughfare = 2;
  1665. this.question_index = that.talkList.length - 1;
  1666. this.answer_index = that.talkList.length - 2;
  1667. if (that.talkList.length > 2) {
  1668. answer = that.talkList[that.question_index - 2].content;
  1669. }
  1670. // let param = {
  1671. // max_tokens: 3000,
  1672. // model: 'gpt-3.5-turbo-0301',
  1673. // stream: true,
  1674. // messages: [{
  1675. // role: 'assistant',
  1676. // content: answer
  1677. // },
  1678. // {
  1679. // role: 'system',
  1680. // content: that.homeTemplate.mode[that.selectornot].guide
  1681. // },
  1682. // {
  1683. // role: 'user',
  1684. // content: e
  1685. // }
  1686. // ]
  1687. // };
  1688. let param = {
  1689. type: that.showchat4 ? 'gpt4' : 'gpt35',
  1690. prompt: e,
  1691. answer: answer,
  1692. guide: that.homeTemplate.mode[that.selectornot].guide,
  1693. // messages: [{
  1694. // role: 'assistant',
  1695. // content: answer
  1696. // },
  1697. // {
  1698. // role: 'system',
  1699. // content: that.homeTemplate.mode[that.selectornot].guide
  1700. // },
  1701. // {
  1702. // role: 'user',
  1703. // content: e
  1704. // }
  1705. // ]
  1706. };
  1707. let headers = {
  1708. 'token': uni.getStorageSync("token") || "",
  1709. 'platform': this.platform,
  1710. 'Content-Type': 'application/json',
  1711. }
  1712. fetch(that.chatgpturl, {
  1713. method: 'POST',
  1714. body: JSON.stringify(param),
  1715. headers: headers
  1716. })
  1717. .then(x => {
  1718. // console.log(x);
  1719. if (x.status === 404) {
  1720. // that.showdirect = true;
  1721. this.showdirect = false;
  1722. that.directGpt(e, answer)
  1723. return;
  1724. }
  1725. if (x.status === 200) return x.body;
  1726. throw x;
  1727. })
  1728. .then(x => {
  1729. const k = x.getReader();
  1730. return new ReadableStream({
  1731. start(V) {
  1732. function F() {
  1733. k.read().then(({
  1734. done: E,
  1735. value: U
  1736. }) => {
  1737. if (E) {
  1738. // console.log('s');
  1739. if (that.talkList[that.question_index].content ==
  1740. '正在思考中...' || that.talkList[that.question_index]
  1741. .content == '请等我几秒钟,正在输入回答...') {
  1742. return;
  1743. }
  1744. // that.timing = that.appInfo.text_expire_time ? Number(that
  1745. // .appInfo.text_expire_time) : 30;
  1746. // that.showcontext = true;
  1747. // that.getcontext();
  1748. that.talkList[that.question_index].show_flash = false;
  1749. that.talkList[that.question_index].done = true;
  1750. that.getUserData();
  1751. // console.log(that.talkList);
  1752. // console.log(that.userData.vip_info);
  1753. // if(that.userData.is_validity > 0&&that.userData.vip_info&&that.userData.vip_info.gpt4_used == 1 || that.userData.is_validity > 0&&that.userData.vip_info&&that.userData.vip_info.gpt35_used == 1){
  1754. // var sty = '会员套餐内当前提问次数已用完,继续提问将会消耗您的'+that.appInfo.number_alias?that.appInfo.number_alias:'点数'
  1755. // uni.showModal({
  1756. // showCancel:false,
  1757. // title:'提示',
  1758. // confirmColor:'#26B3A0',
  1759. // confirmText:'我知道了',
  1760. // content:sty
  1761. // })
  1762. // }
  1763. setTimeout(() => {
  1764. if (that.followornot) {
  1765. uni.pageScrollTo({
  1766. scrollTop: 99999,
  1767. duration: 300
  1768. });
  1769. }
  1770. }, 100);
  1771. return;
  1772. }
  1773. V.enqueue(U);
  1774. // console.log(U);
  1775. const L = new TextDecoder().decode(U);
  1776. const N = L;
  1777. // console.log(L);
  1778. // console.log('5');
  1779. that.showanswer = true;
  1780. if (N != undefined) {
  1781. message += N;
  1782. }
  1783. if (that.thoroughfare == 2) {
  1784. if (N == '内容包含敏感信息,不予展示。') {
  1785. that.talkList[that.question_index - 1].content =
  1786. '该问题已被隐藏!';
  1787. that.talkList[that.question_index].content =
  1788. '内容包含敏感信息,不予展示。';
  1789. that.talkList[that.question_index].show_flash = false;
  1790. that.talkList[that.question_index].done = true;
  1791. return;
  1792. }
  1793. // console.log(JSON.parse(N));
  1794. that.talkList[that.question_index].backups = message;
  1795. that.talkList[that.question_index].content = marked(message);
  1796. // console.log(marked(message));
  1797. }
  1798. if (that.followornot) {
  1799. uni.pageScrollTo({
  1800. scrollTop: 99999,
  1801. duration: 0
  1802. });
  1803. }
  1804. F();
  1805. });
  1806. }
  1807. F();
  1808. }
  1809. });
  1810. })
  1811. .then(x =>
  1812. new Response(x, {
  1813. headers: {
  1814. 'Content-Type': 'text/html'
  1815. }
  1816. }).text()
  1817. );
  1818. },
  1819. // 记录回答
  1820. record(question, answer) {
  1821. let that = this,type = that.showchat4 ? 'gpt4' : 'gpt35';
  1822. this.$http('question.add', {
  1823. question,
  1824. answer,
  1825. type
  1826. }).then(res => {
  1827. if (res.code == 0) {
  1828. that.getUserData();
  1829. // console.log(that.getUserData());
  1830. } else {
  1831. that.talkList[that.question_index].content = res.msg;
  1832. that.talkList[that.question_index - 1].content = '该问题已被隐藏!';
  1833. that.talkList[that.question_index].show_flash = false;
  1834. that.talkList[that.question_index].done = true;
  1835. that.talkList[that.question_index].donec = true;
  1836. }
  1837. });
  1838. },
  1839. // 复制文本
  1840. copyText(e) {
  1841. // console.log(marked(this.talkList[e].content));
  1842. uni.setClipboardData({
  1843. data: this.talkList[e].backups,
  1844. success: function() {
  1845. // console.log('success');
  1846. uni.showToast({
  1847. title: '复制成功'
  1848. });
  1849. }
  1850. });
  1851. },
  1852. // 插屏广告显示时间
  1853. showInterstitial() {
  1854. time2 = setInterval(
  1855. function() {
  1856. interstitialAd.show().catch(err => {
  1857. // console.error(err);
  1858. });
  1859. },
  1860. this.appInfo.gap ? this.appInfo.gap * 1000 : 12000
  1861. );
  1862. },
  1863. // 生成图片
  1864. toSave() {
  1865. uni.showLoading({
  1866. title: '海报生成中'
  1867. });
  1868. this.$refs.painter.canvasToTempFilePathSync({
  1869. // 在nvue里是jpeg
  1870. fileType: 'jpg',
  1871. quality: 1,
  1872. success: res => {
  1873. // H5 提示用户长按图另存
  1874. // #ifdef MP-WEIXIN
  1875. wx.showShareImageMenu({
  1876. path: res.tempFilePath
  1877. })
  1878. this.showPoster = false;
  1879. uni.hideLoading();
  1880. // #endif
  1881. // #ifdef H5
  1882. this.showPoster = false;
  1883. uni.hideLoading();
  1884. uni.showModal({
  1885. confirmColor: '#26B3A0',
  1886. confirmText: '查看图片',
  1887. title: '提示',
  1888. content: '查看图片后长按图片即可保存或分享',
  1889. success(src) {
  1890. if (src.confirm) {
  1891. uni.previewImage({
  1892. urls: [res.tempFilePath]
  1893. });
  1894. } else if (src.cancel) {
  1895. this.showPoster = true;
  1896. }
  1897. }
  1898. });
  1899. // #endif
  1900. }
  1901. });
  1902. },
  1903. //选择角色
  1904. onselect(e) {
  1905. if (this.selectornot != e) {
  1906. let data = {
  1907. content: uni.$u.trim(this.homeTemplate.mode[e].greetings),
  1908. type: 1,
  1909. toid: this.toid,
  1910. fromid: -1,
  1911. avatar: this.homeTemplate.mode[e].img_file.path,
  1912. nickname: this.homeTemplate.mode[e].name,
  1913. done: true,
  1914. donec: true
  1915. };
  1916. this.talkList.push(data);
  1917. this.$nextTick(() => {
  1918. uni.pageScrollTo({
  1919. scrollTop: 99999,
  1920. duration: 300
  1921. });
  1922. });
  1923. }
  1924. // this.showcontext = false
  1925. this.switchmodel = this.selectornot == e ? true : false;
  1926. this.selectornot = e;
  1927. // #ifdef H5
  1928. this.zhuangtai = this.homeTemplate.mode[e].name;
  1929. // #endif
  1930. },
  1931. getdownload(e,type){
  1932. return new Promise((resolve, reject) => {
  1933. // uni.getImageInfo({
  1934. // src: e,
  1935. // success: res => {
  1936. // uni.downloadFile({
  1937. // url: e,
  1938. // success: (res) => {
  1939. // if (res.statusCode === 200) {
  1940. // resolve(res.tempFilePath);
  1941. // }
  1942. // if(res.statusCode === 404){
  1943. // let head = '/static/images/head.jpg',open = '/static/images/open.png';
  1944. // if(type == 1){
  1945. // resolve(head);
  1946. // }else{
  1947. // resolve(open);
  1948. // }
  1949. // }
  1950. // }
  1951. // });
  1952. // },
  1953. // fail: err => {
  1954. // let head = '/static/images/head.jpg',open = '/static/images/open.png';
  1955. // if(type == 1){
  1956. // resolve(head);
  1957. // }else{
  1958. // resolve(open);
  1959. // }
  1960. // }
  1961. // })
  1962. uni.request({
  1963. url: e,
  1964. method:'GET',
  1965. responseType:'arraybuffer',
  1966. success: ress => {
  1967. let base64 = wx.arrayBufferToBase64(ress.data);
  1968. base64 = 'data:image/jpeg;base64,' + base64
  1969. resolve(base64);
  1970. },
  1971. fail: (e) => {
  1972. let head = '/static/images/head.jpg',open = '/static/images/open.png';
  1973. if(type == 1){
  1974. resolve(head);
  1975. }else{
  1976. resolve(open);
  1977. }
  1978. }
  1979. })
  1980. });
  1981. },
  1982. posterSuccess(){
  1983. uni.hideLoading();
  1984. },
  1985. // 海报绘制
  1986. async createPoster(e) {
  1987. let that = this;
  1988. let site_logo = '';
  1989. uni.showLoading({
  1990. title: '海报渲染中'
  1991. });
  1992. let avatar_logo = that.userInfo.avatar ? await this.getdownload(that.userInfo.avatar,1):'/static/images/head.jpg';
  1993. if(that.appInfo.site_logo_path.indexOf("https") < 0){
  1994. site_logo = that.appInfo.site_logo_path ? await that.getdownload(that.appInfo.site_logo_path.replace("http:", "https:"),2):'/static/images/open.png';
  1995. }else{
  1996. site_logo = that.appInfo.site_logo_path ? await that.getdownload(that.appInfo.site_logo_path,2):'/static/images/open.png';
  1997. }
  1998. (this.posterObj = {
  1999. width: uni.$u.sys().windowWidth+ 'px',
  2000. background: 'linear-gradient(to right, #00ca88 0%, #00BCD4 100%)',
  2001. css: {
  2002. // 根节点若无尺寸,自动获取父级节点
  2003. width: uni.$u.sys().windowWidth+ 'px',
  2004. },
  2005. views: [{
  2006. type: 'view',
  2007. css: {
  2008. marginTop: '20rpx',
  2009. paddingLeft: '10rpx',
  2010. display: 'flex'
  2011. },
  2012. views: [{
  2013. type: 'image',
  2014. src: avatar_logo,
  2015. css: {
  2016. marginTop: '10rpx',
  2017. marginLeft: '20rpx',
  2018. borderRadius: '16rpx',
  2019. width: '80rpx',
  2020. height: '80rpx',
  2021. border: '2rpx solid #fff',
  2022. objectFit: 'cover'
  2023. }
  2024. },
  2025. {
  2026. type: 'view',
  2027. css: {
  2028. marginTop: '10rpx',
  2029. marginLeft: '20rpx'
  2030. // display:'flex',
  2031. // flexDirection:'column'
  2032. },
  2033. views: [{
  2034. type: 'view',
  2035. views: [{
  2036. type: 'text',
  2037. text: this.userInfo.nickname ? this
  2038. .userInfo
  2039. .nickname : '提问者',
  2040. css: {
  2041. marginTop: '10rpx',
  2042. fontSize: '28rpx',
  2043. fontWeight: 'bold',
  2044. color: '#32324A',
  2045. lineHeight: '28rpx'
  2046. }
  2047. }]
  2048. },
  2049. {
  2050. type: 'view',
  2051. views: [{
  2052. type: 'text',
  2053. text: '我的提问❓',
  2054. css: {
  2055. marginTop: '15rpx',
  2056. fontSize: '20rpx',
  2057. color: '#fff',
  2058. lineHeight: '25rpx',
  2059. }
  2060. }]
  2061. }
  2062. ]
  2063. }
  2064. ]
  2065. },
  2066. {
  2067. type: 'view',
  2068. css: {
  2069. marginTop: '20rpx',
  2070. width: (uni.$u.sys().windowWidth - 48) + 'px',
  2071. padding: '15rpx',
  2072. background: '#fff',
  2073. borderRadius: '16rpx',
  2074. marginLeft: '30rpx',
  2075. },
  2076. views: [{
  2077. type: 'text',
  2078. text: that.talkList[e - 1].content,
  2079. css: {
  2080. fontSize: '28rpx',
  2081. color: '#000',
  2082. // lineHeight: '45rpx',
  2083. // lineClamp: 2,
  2084. // padding: '10rpx',
  2085. // paddingRight: '10rpx',
  2086. width: (uni.$u.sys().windowWidth - 48) + 'px',
  2087. // padding:'10rpx'
  2088. }
  2089. }]
  2090. },
  2091. {
  2092. type: 'view',
  2093. css: {
  2094. marginTop: '20rpx',
  2095. paddingLeft: '10rpx',
  2096. display: 'flex'
  2097. },
  2098. views: [{
  2099. type: 'image',
  2100. src: site_logo,
  2101. css: {
  2102. marginTop: '10rpx',
  2103. marginLeft: '20rpx',
  2104. borderRadius: '16rpx',
  2105. width: '80rpx',
  2106. height: '80rpx',
  2107. border: '2rpx solid #fff',
  2108. objectFit: 'cover'
  2109. }
  2110. },
  2111. {
  2112. type: 'view',
  2113. css: {
  2114. marginTop: '10rpx',
  2115. marginLeft: '20rpx'
  2116. // display:'flex',
  2117. // flexDirection:'column'
  2118. },
  2119. views: [{
  2120. type: 'view',
  2121. views: [{
  2122. type: 'text',
  2123. text: this.appInfo.site_name ? this
  2124. .appInfo
  2125. .site_name : 'AI智能问答机器人',
  2126. css: {
  2127. marginTop: '10rpx',
  2128. fontSize: '28rpx',
  2129. fontWeight: 'bold',
  2130. color: '#32324A',
  2131. lineHeight: '28rpx'
  2132. }
  2133. }]
  2134. },
  2135. {
  2136. type: 'view',
  2137. views: [{
  2138. type: 'text',
  2139. text: '回答结果📝',
  2140. css: {
  2141. marginTop: '15rpx',
  2142. fontSize: '20rpx',
  2143. color: '#fff',
  2144. lineHeight: '25rpx',
  2145. }
  2146. }]
  2147. }
  2148. ]
  2149. }
  2150. ]
  2151. },
  2152. {
  2153. type: 'view',
  2154. css: {
  2155. marginTop: '20rpx',
  2156. width: (uni.$u.sys().windowWidth - 48) + 'px',
  2157. padding: '15rpx',
  2158. background: '#fff',
  2159. borderRadius: '16rpx',
  2160. marginLeft: '30rpx',
  2161. },
  2162. views: [{
  2163. type: 'text',
  2164. text: uni.$u.trim(that.talkList[e].backups),
  2165. css: {
  2166. fontSize: '28rpx',
  2167. color: '#000',
  2168. // lineHeight: '45rpx',
  2169. // lineClamp: 11,
  2170. width: (uni.$u.sys().windowWidth - 48) + 'px',
  2171. // padding: '10rpx',
  2172. }
  2173. }]
  2174. },
  2175. {
  2176. type: 'view',
  2177. css: {
  2178. marginTop: '30rpx',
  2179. width: '100%',
  2180. textAlign: 'center'
  2181. },
  2182. // #ifdef H5
  2183. views: [{
  2184. type: 'qrcode',
  2185. text: this.qrcode,
  2186. css: {
  2187. width: '200rpx',
  2188. height: '200rpx',
  2189. borderRadius: '16rpx',
  2190. }
  2191. }],
  2192. // #endif
  2193. // #ifdef MP-WEIXIN
  2194. views: [{
  2195. type: 'image',
  2196. src: this.qrcode,
  2197. css: {
  2198. width: '200rpx',
  2199. height: '200rpx',
  2200. borderRadius: '16rpx',
  2201. }
  2202. }]
  2203. // #endif
  2204. },
  2205. {
  2206. type: 'text',
  2207. text: '———— ' + '长按识别 | 欢迎使用' + ' ————',
  2208. css: {
  2209. marginTop: '20rpx',
  2210. marginBottom: '20rpx',
  2211. width: '100%',
  2212. textAlign: 'center',
  2213. fontSize: '24rpx',
  2214. color: '#fff',
  2215. lineHeight: '33rpx'
  2216. }
  2217. }
  2218. ]
  2219. }),
  2220. (this.showPoster = true);
  2221. }
  2222. }
  2223. };
  2224. </script>
  2225. <style lang="scss">
  2226. @import '@/pages/chat/global.scss';
  2227. page {
  2228. background-color: #f1f1f1;
  2229. font-size: 28rpx;
  2230. }
  2231. .ask {
  2232. color: #26b3a0;
  2233. margin-top: 22rpx;
  2234. }
  2235. /* 加载数据提示 */
  2236. .tips {
  2237. // bottom: ;
  2238. position: fixed;
  2239. left: 0;
  2240. top: var(--window-top);
  2241. width: 100%;
  2242. z-index: 9;
  2243. background-color: rgba(0, 0, 0, 0.15);
  2244. height: 72rpx;
  2245. line-height: 72rpx;
  2246. transform: translateY(-80rpx);
  2247. transition: transform 0.3s ease-in-out 0s;
  2248. &.show {
  2249. transform: translateY(0);
  2250. }
  2251. }
  2252. .box-1 {
  2253. width: 100%;
  2254. height: auto;
  2255. padding-bottom: 138rpx;
  2256. box-sizing: content-box;
  2257. /* 兼容iPhoneX */
  2258. margin-bottom: 0;
  2259. margin-bottom: constant(safe-area-inset-bottom);
  2260. margin-bottom: env(safe-area-inset-bottom);
  2261. }
  2262. .box-2 {
  2263. position: fixed;
  2264. left: 0;
  2265. width: 100%;
  2266. bottom: 0;
  2267. height: auto;
  2268. // border-radius: 30rpx 30rpx 0 0;
  2269. z-index: 2;
  2270. border-top: #9e9e9e38 solid 1px;
  2271. // border-bottom: #e5e5e5 solid 1px;
  2272. box-sizing: content-box;
  2273. background-color: #ffffff;
  2274. /* 兼容iPhoneX */
  2275. padding-bottom: 0;
  2276. padding-bottom: constant(safe-area-inset-bottom);
  2277. padding-bottom: env(safe-area-inset-bottom);
  2278. >view {
  2279. padding: 0 20rpx;
  2280. height: 150rpx;
  2281. }
  2282. .content {
  2283. background-color: #f1f1f1;
  2284. height: 64rpx;
  2285. width: 100%;
  2286. padding: 15rpx 20rpx 0;
  2287. border-radius: 32rpx;
  2288. // font-size: 28rpx;
  2289. }
  2290. .send {
  2291. background: linear-gradient(to right, #00ca88, #00BCD4);
  2292. color: #fff;
  2293. height: 75rpx;
  2294. margin-left: 20rpx;
  2295. border-radius: 50rpx;
  2296. padding: 0;
  2297. width: 138rpx;
  2298. font-size: 30rpx;
  2299. font-weight: bold;
  2300. line-height: 75rpx;
  2301. &:active {
  2302. background-color: #26b3a08a;
  2303. }
  2304. }
  2305. }
  2306. .talk-list {
  2307. padding-bottom: 20rpx;
  2308. /* 消息项,基础类 */
  2309. .item {
  2310. padding: 20rpx 20rpx 0 20rpx;
  2311. align-items: flex-start;
  2312. align-content: flex-start;
  2313. color: #333;
  2314. .pic {
  2315. width: 100rpx;
  2316. height: 100rpx;
  2317. border-radius: 50%;
  2318. border: #fff solid 1px;
  2319. }
  2320. .content {
  2321. font-weight: bold;
  2322. padding: 15rpx 25rpx;
  2323. border-radius: 4px;
  2324. max-width: 500rpx;
  2325. word-break: break-all;
  2326. line-height: 52rpx;
  2327. position: relative;
  2328. }
  2329. /* 收到的消息 */
  2330. &.pull {
  2331. .time {
  2332. margin-left: 22rpx;
  2333. font-size: 24rpx;
  2334. margin-bottom: 15rpx;
  2335. color: #9e9e9e;
  2336. position: absolute;
  2337. width: 300rpx;
  2338. top: 0rpx;
  2339. left: 0rpx;
  2340. }
  2341. .content {
  2342. margin-left: 22rpx;
  2343. background-color: #fff;
  2344. border-radius: 0px 8px 8px 8px;
  2345. margin-top: 45rpx;
  2346. // &::after{
  2347. // content: '';
  2348. // display: block;
  2349. // width: 0;
  2350. // height: 0;
  2351. // border-top: 16rpx solid transparent;
  2352. // border-bottom: 16rpx solid transparent;
  2353. // border-right: 20rpx solid #fff;
  2354. // position: absolute;
  2355. // top: 30rpx;
  2356. // left: -18rpx;
  2357. // }
  2358. }
  2359. .sentpictures {
  2360. width: 300rpx;
  2361. // height: 237.5rpx;
  2362. margin-left: 22rpx;
  2363. border-radius: 0px 8px 8px 8px;
  2364. margin-top: 46rpx;
  2365. }
  2366. }
  2367. /* 发出的消息 */
  2368. &.push {
  2369. /* 主轴为水平方向,起点在右端。使不修改DOM结构,也能改变元素排列顺序 */
  2370. flex-direction: row-reverse;
  2371. .time {
  2372. margin-right: 22rpx;
  2373. font-size: 24rpx;
  2374. margin-bottom: 15rpx;
  2375. color: #9e9e9e;
  2376. position: absolute;
  2377. width: 300rpx;
  2378. top: 0rpx;
  2379. right: 0rpx;
  2380. display: flex;
  2381. justify-content: flex-end;
  2382. }
  2383. .content {
  2384. margin-right: 22rpx;
  2385. background-color: #26b3a0;
  2386. color: #fff;
  2387. border-radius: 8px 0px 8px 8px;
  2388. margin-top: 45rpx;
  2389. }
  2390. .sentpictures {
  2391. width: 300rpx;
  2392. margin-right: 22rpx;
  2393. border-radius: 8px 0 8px 8px;
  2394. margin-top: 46rpx;
  2395. }
  2396. }
  2397. }
  2398. }
  2399. .flex_photo {
  2400. // width: 80rpx;
  2401. border-radius: 50%;
  2402. background: #f1f1f1;
  2403. padding: 12rpx;
  2404. margin-right: 20rpx;
  2405. }
  2406. .content {
  2407. width: 100%;
  2408. .msg-list {
  2409. // width: 95%;
  2410. // padding: 38rpx 20rpx 237rpx 20rpx;
  2411. padding: 20rpx;
  2412. // position: absolute;
  2413. // top: 0rpx;
  2414. // bottom: 130rpx;
  2415. // margin-bottom: constant(safe-area-inset-bottom);
  2416. // margin-bottom: env(safe-area-inset-bottom);
  2417. .loading {
  2418. //loading动画
  2419. display: flex;
  2420. justify-content: center;
  2421. @keyframes stretchdelay {
  2422. 0%,
  2423. 40%,
  2424. 100% {
  2425. transform: scaleY(0.6);
  2426. }
  2427. 20% {
  2428. transform: scaleY(1);
  2429. }
  2430. }
  2431. .spinner {
  2432. margin: 20rpx 0;
  2433. width: 60rpx;
  2434. height: 100rpx;
  2435. display: flex;
  2436. align-items: center;
  2437. justify-content: space-between;
  2438. view {
  2439. background-color: #f06c7a;
  2440. height: 50rpx;
  2441. width: 6rpx;
  2442. border-radius: 6rpx;
  2443. animation: stretchdelay 1.2s infinite ease-in-out;
  2444. }
  2445. .rect2 {
  2446. animation-delay: -1.1s;
  2447. }
  2448. .rect3 {
  2449. animation-delay: -1s;
  2450. }
  2451. .rect4 {
  2452. animation-delay: -0.9s;
  2453. }
  2454. .rect5 {
  2455. animation-delay: -0.8s;
  2456. }
  2457. }
  2458. }
  2459. .row {
  2460. .system {
  2461. display: flex;
  2462. justify-content: center;
  2463. view {
  2464. padding: 0 30rpx;
  2465. height: 50rpx;
  2466. display: flex;
  2467. justify-content: center;
  2468. align-items: center;
  2469. background-color: #c9c9c9;
  2470. color: #fff;
  2471. font-size: 24rpx;
  2472. border-radius: 40rpx;
  2473. }
  2474. .red-envelope {
  2475. image {
  2476. margin-right: 5rpx;
  2477. width: 30rpx;
  2478. height: 30rpx;
  2479. }
  2480. }
  2481. }
  2482. &:first-child {
  2483. // margin-top: 20rpx;
  2484. }
  2485. padding: 15rpx 0;
  2486. .my .left,
  2487. .other .right {
  2488. width: 86%;
  2489. display: flex;
  2490. .bubble {
  2491. max-width: 90%;
  2492. min-height: 50rpx;
  2493. // border-radius: 13rpx;
  2494. // padding: 22rpx 30rpx;
  2495. display: flex;
  2496. align-items: center;
  2497. font-size: 30rpx;
  2498. word-break: break-word;
  2499. &.img {
  2500. background-color: transparent;
  2501. padding: 0;
  2502. overflow: hidden;
  2503. image {
  2504. max-width: 300rpx;
  2505. // max-height: 350rpx;
  2506. }
  2507. }
  2508. &.red-envelope {
  2509. background-color: transparent;
  2510. padding: 0;
  2511. overflow: hidden;
  2512. position: relative;
  2513. justify-content: center;
  2514. align-items: flex-start;
  2515. image {
  2516. width: 250rpx;
  2517. height: 313rpx;
  2518. }
  2519. .tis {
  2520. position: absolute;
  2521. top: 6%;
  2522. font-size: 26rpx;
  2523. color: #9c1712;
  2524. }
  2525. .blessing {
  2526. position: absolute;
  2527. bottom: 14%;
  2528. color: #e9b874;
  2529. width: 80%;
  2530. text-align: center;
  2531. overflow: hidden;
  2532. // 最多两行
  2533. display: -webkit-box;
  2534. -webkit-box-orient: vertical;
  2535. -webkit-line-clamp: 2;
  2536. }
  2537. }
  2538. &.voice {
  2539. .icon {
  2540. font-size: 40rpx;
  2541. display: flex;
  2542. align-items: center;
  2543. }
  2544. .icon:after {
  2545. content: ' ';
  2546. width: 53rpx;
  2547. height: 53rpx;
  2548. border-radius: 100%;
  2549. position: absolute;
  2550. box-sizing: border-box;
  2551. }
  2552. .length {
  2553. font-size: 28rpx;
  2554. }
  2555. }
  2556. }
  2557. }
  2558. .my .right,
  2559. .other .left {
  2560. flex-shrink: 0;
  2561. // width: 84rpx;
  2562. // height: 84rpx;
  2563. // image {
  2564. // width: 80rpx;
  2565. // height: 80rpx;
  2566. // border-radius: 50%;
  2567. // }
  2568. }
  2569. .my {
  2570. width: 100%;
  2571. display: flex;
  2572. justify-content: flex-end;
  2573. .left {
  2574. min-height: 80rpx;
  2575. flex-wrap: wrap;
  2576. align-items: center;
  2577. justify-content: flex-end;
  2578. .bubbleimg {
  2579. image {
  2580. height: 300rpx;
  2581. width: 400rpx;
  2582. border-radius: 10px 0px 10px 10px;
  2583. }
  2584. }
  2585. .bubble {
  2586. border-radius: 20rpx 0rpx 20rpx 20rpx;
  2587. }
  2588. .username {
  2589. width: 100%;
  2590. height: 48rpx;
  2591. font-size: 26rpx;
  2592. color: #999;
  2593. display: flex;
  2594. justify-content: flex-end;
  2595. .name {
  2596. // margin-right: 50rpx;
  2597. }
  2598. }
  2599. .bubble {
  2600. background: linear-gradient(to right, #00ca88, #00BCD4);
  2601. color: #000;
  2602. font-size: 30rpx;
  2603. &.voice {
  2604. .icon {
  2605. color: #fff;
  2606. }
  2607. .length {
  2608. margin-right: 20rpx;
  2609. }
  2610. }
  2611. &.play {
  2612. @keyframes my-play {
  2613. 0% {
  2614. transform: translateX(80%);
  2615. }
  2616. 100% {
  2617. transform: translateX(0%);
  2618. }
  2619. }
  2620. .icon:after {
  2621. border-left: solid 10rpx rgba(240, 108, 122, 0.5);
  2622. animation: my-play 1s linear infinite;
  2623. }
  2624. }
  2625. }
  2626. }
  2627. .right {
  2628. margin-left: 22rpx;
  2629. }
  2630. }
  2631. .other {
  2632. width: 100%;
  2633. display: flex;
  2634. .bubbleimg {
  2635. image {
  2636. width: 400rpx;
  2637. height: 300rpx;
  2638. border-radius: 0px 10px 10px 10px;
  2639. }
  2640. }
  2641. .bubble {
  2642. border-radius: 0rpx 20rpx 20rpx 20rpx;
  2643. }
  2644. .left {
  2645. margin-right: 22rpx;
  2646. }
  2647. .tip {
  2648. display: flex;
  2649. flex-direction: column;
  2650. position: absolute;
  2651. justify-content: space-between;
  2652. right: -50rpx;
  2653. bottom: 0;
  2654. height: 92rpx;
  2655. }
  2656. .right {
  2657. flex-wrap: wrap;
  2658. .username {
  2659. width: 100%;
  2660. height: 48rpx;
  2661. font-size: 26rpx;
  2662. color: #999;
  2663. display: flex;
  2664. .name {
  2665. // margin-right: 50rpx;
  2666. }
  2667. }
  2668. .bubble {
  2669. // background-color: #fff;
  2670. color: #333;
  2671. &.voice {
  2672. .icon {
  2673. color: #333;
  2674. }
  2675. .length {
  2676. margin-left: 20rpx;
  2677. }
  2678. }
  2679. &.play {
  2680. @keyframes other-play {
  2681. 0% {
  2682. transform: translateX(-80%);
  2683. }
  2684. 100% {
  2685. transform: translateX(0%);
  2686. }
  2687. }
  2688. .icon:after {
  2689. border-right: solid 10rpx rgba(255, 255, 255, 0.8);
  2690. animation: other-play 1s linear infinite;
  2691. }
  2692. }
  2693. }
  2694. }
  2695. }
  2696. .exchange {
  2697. font-weight: bold;
  2698. font-size: 30rpx;
  2699. background: #00000014;
  2700. padding: 15rpx 35rpx;
  2701. border-radius: 45rpx;
  2702. .launch {
  2703. margin-right: 35rpx;
  2704. }
  2705. .agree {
  2706. color: #4095e5;
  2707. margin-right: 25rpx;
  2708. }
  2709. .refuse {
  2710. color: #fe7058;
  2711. }
  2712. }
  2713. }
  2714. }
  2715. }
  2716. .ability {
  2717. width: 100%;
  2718. position: fixed;
  2719. top: 0;
  2720. height: 115rpx;
  2721. background: #ffffff;
  2722. z-index: 9;
  2723. border-bottom: #e5e5e5 solid 1px;
  2724. .item_ability {
  2725. width: 20%;
  2726. .t_ability {
  2727. font-size: 26rpx;
  2728. margin-top: 6rpx;
  2729. }
  2730. }
  2731. }
  2732. .flash {
  2733. margin-left: 2px;
  2734. animation: flash 0.8s linear infinite;
  2735. }
  2736. // 实现光标闪烁
  2737. @keyframes flash {
  2738. from {
  2739. opacity: 0;
  2740. }
  2741. to {
  2742. opacity: 1;
  2743. }
  2744. }
  2745. .neckBtn_view {
  2746. align-items: center;
  2747. display: flex;
  2748. justify-content: center;
  2749. position: fixed;
  2750. flex-direction: column;
  2751. background: linear-gradient(-45deg, #26b3a0, #3edd3e);
  2752. border-radius: 100rpx 0 0 100rpx;
  2753. box-shadow: 0rpx 10rpx 10rpx 0rpx rgba(0, 0, 0, 0.2);
  2754. box-sizing: border-box;
  2755. color: #fff;
  2756. font-size: 25rpx;
  2757. line-height: 30rpx;
  2758. padding: 10rpx 25rpx 10rpx;
  2759. right: 0;
  2760. text-align: center;
  2761. bottom: 415rpx;
  2762. .free_view {
  2763. font-size: 28rpx;
  2764. margin-bottom: 6rpx;
  2765. }
  2766. }
  2767. .poster-img {
  2768. width: 670rpx;
  2769. height: 928rpx;
  2770. position: relative;
  2771. text {
  2772. background: url('https://s.yun-live.com/images/20210201/5c4ef9d86bc5eec90f2f915683d9db08.png') no-repeat;
  2773. background-size: 100% 100%;
  2774. display: inline-block;
  2775. width: 50rpx;
  2776. height: 50rpx;
  2777. position: absolute;
  2778. top: -60rpx;
  2779. right: 0;
  2780. }
  2781. image {
  2782. width: 100%;
  2783. height: 100%;
  2784. }
  2785. view {
  2786. font-size: 32rpx;
  2787. font-family: PingFang-SC-Bold, PingFang-SC;
  2788. font-weight: bold;
  2789. color: #ffffff;
  2790. line-height: 32rpx;
  2791. text-align: center;
  2792. margin-top: 28rpx;
  2793. }
  2794. }
  2795. .poster {
  2796. padding: 40rpx;
  2797. .footer-btn {
  2798. margin-top: 24rpx;
  2799. display: flex;
  2800. align-items: center;
  2801. justify-content: space-between;
  2802. view {
  2803. width: 319rpx;
  2804. height: 66rpx;
  2805. border-radius: 40rpx;
  2806. border: 1px solid #4070ff;
  2807. font-size: 26rpx;
  2808. font-family: PingFangSC-Regular, PingFang SC;
  2809. font-weight: 400;
  2810. color: #4070ff;
  2811. line-height: 66rpx;
  2812. text-align: center;
  2813. }
  2814. .save {
  2815. background: #4070ff;
  2816. color: #ffffff;
  2817. }
  2818. }
  2819. }
  2820. .poster-btn {
  2821. position: fixed;
  2822. bottom: 0;
  2823. left: 0;
  2824. width: 100%;
  2825. height: 140rpx;
  2826. background: #ffffff;
  2827. border-radius: 32rpx 32rpx 0px 0px;
  2828. display: flex;
  2829. align-items: center;
  2830. justify-content: space-around;
  2831. >view {
  2832. width: 80rpx;
  2833. height: 80rpx;
  2834. position: relative;
  2835. border-radius: 10rpx;
  2836. border: 4rpx solid #fff;
  2837. &.is-check {
  2838. border: 4rpx solid #4070ff;
  2839. }
  2840. image {
  2841. width: 100%;
  2842. height: 100%;
  2843. }
  2844. view {
  2845. width: 30rpx;
  2846. height: 30rpx;
  2847. position: absolute;
  2848. right: -15rpx;
  2849. bottom: -15rpx;
  2850. background: url('https://s.yun-live.com/images/20210201/311c01265c1aa508418f6bae10d67602.png') no-repeat;
  2851. background-size: 100% 100%;
  2852. }
  2853. }
  2854. }
  2855. .select {
  2856. font-weight: bold;
  2857. font-size: 32rpx;
  2858. margin: 30rpx;
  2859. }
  2860. .model_view {
  2861. margin: 30rpx;
  2862. .modelname {
  2863. font-size: 32rpx;
  2864. font-weight: bold;
  2865. width: 56%;
  2866. .name {
  2867. overflow: hidden;
  2868. white-space: nowrap;
  2869. text-overflow: ellipsis;
  2870. }
  2871. .modeldetails {
  2872. font-size: 26rpx;
  2873. font-weight: 500;
  2874. margin-top: 12rpx;
  2875. color: #9e9e9e;
  2876. overflow: hidden;
  2877. text-overflow: ellipsis;
  2878. display: -webkit-box;
  2879. -webkit-line-clamp: 2;
  2880. -webkit-box-orient: vertical;
  2881. }
  2882. }
  2883. .modelselect {
  2884. background: #03a9f4;
  2885. border-radius: 14rpx;
  2886. color: #fff;
  2887. width: 58px;
  2888. height: 30px;
  2889. line-height: 30px;
  2890. text-align: center;
  2891. }
  2892. }
  2893. .expand {
  2894. // padding: 20rpx;
  2895. // margin: 20rpx 20rpx 155rpx 20rpx;
  2896. // padding-bottom: env(safe-area-inset-bottom);
  2897. margin-left: 20rpx;
  2898. .surplus {
  2899. font-size: 26rpx;
  2900. background: #fff;
  2901. border-radius: 50rpx;
  2902. padding: 8rpx 12rpx;
  2903. margin-right: 20rpx;
  2904. border: 1px solid #ededed;
  2905. // box-shadow: 0px 0px 10px 3px #f1f1f1;
  2906. .item {
  2907. margin-left: 10rpx;
  2908. }
  2909. // display: inline-block;
  2910. }
  2911. }
  2912. .scroll-view_H {
  2913. white-space: nowrap;
  2914. width: 100%;
  2915. margin-bottom: 177rpx;
  2916. }
  2917. .operate {
  2918. // width: 90%;
  2919. // max-width: 90%;
  2920. margin-top: 12rpx;
  2921. position: relative;
  2922. .dialogue {
  2923. // width: 140rpx;
  2924. // white-space: nowrap;
  2925. // margin-right: 50rpx;
  2926. width: 24px;
  2927. height: 24px;
  2928. background: #68d7bb;
  2929. border-radius: 50%;
  2930. // margin-right: 20rpx;
  2931. }
  2932. .duplicate {
  2933. font-size: 26rpx;
  2934. margin-left: 6rpx;
  2935. color: #9e9e9e;
  2936. }
  2937. .eliseaudio {
  2938. margin-left: 10px;
  2939. }
  2940. .share {
  2941. font-size: 26rpx;
  2942. margin-left: 6rpx;
  2943. color: #9e9e9e;
  2944. }
  2945. .broadcast {
  2946. background: #fff;
  2947. width: 150rpx;
  2948. height: 40rpx;
  2949. border-radius: 60rpx;
  2950. // padding: 0 5rpx;
  2951. .play {
  2952. border-radius: 50%;
  2953. }
  2954. image {
  2955. width: 150rpx;
  2956. height: 40rpx;
  2957. border-radius: 60rpx;
  2958. }
  2959. }
  2960. .hoversubmit {
  2961. background: #9e9e9e61;
  2962. }
  2963. }
  2964. .bottomheight {
  2965. width: 100%;
  2966. height: 217rpx;
  2967. }
  2968. .soundrecording {
  2969. flex-direction: column;
  2970. .discriminate {
  2971. color: #9e9e9e;
  2972. margin-bottom: 30rpx;
  2973. }
  2974. }
  2975. .waveform {
  2976. image {
  2977. width: 468rpx;
  2978. height: 168rpx;
  2979. }
  2980. }
  2981. .operation {
  2982. margin: 60rpx 0 30rpx;
  2983. .affirm {
  2984. margin: 0 42rpx;
  2985. image {
  2986. width: 60rpx;
  2987. height: 60rpx;
  2988. }
  2989. }
  2990. .longpress {
  2991. background: red;
  2992. border-radius: 50%;
  2993. padding: 30rpx;
  2994. image {
  2995. width: 70rpx;
  2996. height: 70rpx;
  2997. }
  2998. }
  2999. .hoversubmit {
  3000. background: #9e9e9e61;
  3001. }
  3002. }
  3003. .env {
  3004. padding-bottom: env(safe-area-inset-bottom);
  3005. }
  3006. .dygbhg {
  3007. background: #ffffff;
  3008. border-radius: 15rpx 15rpx 0 0;
  3009. position: fixed;
  3010. bottom: 0;
  3011. left: 0;
  3012. width: 100%;
  3013. box-shadow: 0px 0px 10px #00000024;
  3014. display: flex;
  3015. align-items: center;
  3016. justify-content: space-evenly;
  3017. }
  3018. .whole{
  3019. width: 45%;
  3020. height: 88rpx;
  3021. display: flex;
  3022. color: #ffffff;
  3023. align-items: center;
  3024. justify-content: center;
  3025. background: #f3f3f3;
  3026. font-weight: bold;
  3027. border-radius: 60rpx;
  3028. color: #3d7eff;
  3029. }
  3030. .distinguish {
  3031. width: 45%;
  3032. height: 88rpx;
  3033. display: flex;
  3034. color: #ffffff;
  3035. align-items: center;
  3036. justify-content: center;
  3037. background: #3d7eff;
  3038. font-weight: bold;
  3039. border-radius: 60rpx;
  3040. margin: 38rpx 0;
  3041. margin-left: 4%;
  3042. }
  3043. .mytheme{
  3044. padding: 12px 16px;
  3045. background: #fff;
  3046. border-radius: 0px 11px 11px 11px;
  3047. // overflow: auto;
  3048. }
  3049. .mycopy{
  3050. width: 24px;
  3051. height: 24px;
  3052. background: #4c4c4c30;
  3053. border-radius: 50%;
  3054. margin-right: 12rpx;
  3055. }
  3056. </style>